/** crash-loader version: 38.18.2 */
"use strict";
var sqCrashLoader = (() => {
  var __defProp = Object.defineProperty;
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  var __getOwnPropNames = Object.getOwnPropertyNames;
  var __hasOwnProp = Object.prototype.hasOwnProperty;
  var __export = (target, all) => {
    for (var name in all)
      __defProp(target, name, { get: all[name], enumerable: true });
  };
  var __copyProps = (to, from, except, desc) => {
    if (from && typeof from === "object" || typeof from === "function") {
      for (let key of __getOwnPropNames(from))
        if (!__hasOwnProp.call(to, key) && key !== except)
          __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
    }
    return to;
  };
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

  // libs/games/crash/loader/src/index.ts
  var index_exports = {};
  __export(index_exports, {
    SqCrashLoader: () => SqCrashLoader,
    SqLoader: () => SqLoader
  });

  // libs/games/crash/loader/src/lib/crash-loader.ts
  var import_meta = {};
  var SqLoader = class {
  };
  var currentScript = document.currentScript;
  var SqCrashLoader = class extends SqLoader {
    constructor(config) {
      super();
      this.config = config;
    }
    /**
     * init
     * @returns Promise<SqCrashLoader>
     */
    async init() {
      const iframe = document.createElement("iframe");
      iframe.src = await this.createIframeUrl(this.config);
      iframe.id = "crash-loader";
      this.config.container.appendChild(iframe);
      return this;
    }
    async createIframeUrl(config) {
      const host = this.getHost();
      const params = (config.serverUrl ? `&serverUrl=${config.serverUrl}` : "") + (config.spServerUrl ? `&spServerUrl=${config.spServerUrl}` : "") + (config.i18nUrl ? `&i18nUrl=${config.i18nUrl}` : "") + (config.provisioningUrl ? `&provisioningUrl=${config.provisioningUrl}` : "") + (config.rulesPath ? `&rulesPath=${config.rulesPath}` : "") + (config.language ? `&language=${config.language}` : "") + (config.domain ? `&domain=${config.domain}` : "") + (config.user ? `&user=${config.user}` : "") + (config.password ? `&password=${config.password}` : "") + (config.hardwareId ? `&hwId=${config.hardwareId}` : "") + (config.onlineHash ? `&onlineHash=${config.onlineHash}` : "") + (config.playlistId ? `&playlistIds=${config.playlistId}` : "");
      return `${host}/?${params.substring(1)}`;
    }
    getHost() {
      let urlString = null;
      if (currentScript) {
        urlString = currentScript.src;
      } else {
        urlString = import_meta.url;
      }
      if (urlString) {
        const hostUrl = new URL(urlString);
        return `${hostUrl.origin}${hostUrl.pathname.split("/").slice(0, -1).join("/")}`.replace("spinmatic-crash", "iframe");
      } else {
        throw new Error("ERROR: Unable to get currentScriptUrl to get the front end url");
      }
    }
  };
  return __toCommonJS(index_exports);
})();
//# sourceMappingURL=loader.js.map
