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AM,EAAkB,OAAO,OAAO,CAAC,EAAG,SAAS,OAAO,UAAW,KAAK,IAAI,QAAQ,WAChF,EAAgB,OAAO,OAAO,CAAC,EAAG,SAAS,OAAO,QAAS,KAAK,IAAI,QAAQ,SAC5E,EAAe,OAAO,OAAO,CAAC,EAAG,SAAS,OAAO,OAAQ,KAAK,IAAI,QAAQ,QAC1E,EAAiB,SAAS,cAAc,OAC9C,KAAK,YAAY,EAAgB,GACjC,MAAM,EAAe,SAAS,cAAc,OAC5C,KAAK,YAAY,EAAc,GAC/B,MAAM,EAAc,SAAS,cAAc,UAC3C,EAAY,YAAc,IAC1B,EAAY,MAAM,QAAU,mSAS5B,EAAY,aAAa,aAAc,SACvC,MAAM,EAAS,SAAS,cAAc,UAoBtC,OAnBA,EAAO,IAAM,EACb,EAAO,aAAa,UAAW,KAAK,IAAI,SAAW,SAAS,SAC5D,EAAO,aAAa,QAAS,KAAK,IAAI,OAAS,SAAS,OACxD,KAAK,YAAY,EAAQ,GACzB,EAAO,iBAAiB,SAAS,KAC/B,MAAM,EAAe,SAAS,cAAc,OAC5C,EAAa,YAAc,0BAC3B,EAAa,YAAY,GACzB,QAAQ,MAAM,0CAA2C,EAAI,IAE/D,EAAa,YAAY,GACzB,EAAa,YAAY,GACzB,EAAe,YAAY,GAC3B,EAAe,iBAAiB,SAAU,IACpC,EAAM,SAAW,GACnB,KAAK,YACP,IAEF,EAAY,iBAAiB,SAAS,IAAM,KAAK,eAC1C,CACT,GAEF,SAAS,iBAAiB,GACxB,OAAO,IAAI,WAAW,EACxB","file":"/npm/viewink@1.0.13/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/viewink@1.0.13/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n  for (var name in all)\n    __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n  if (from && typeof from === \"object\" || typeof from === \"function\") {\n    for (let key of __getOwnPropNames(from))\n      if (!__hasOwnProp.call(to, key) && key !== except)\n        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n  }\n  return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/index.ts\nvar index_exports = {};\n__export(index_exports, {\n  createModalPopup: () => createModalPopup\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// src/defaults.ts\nvar DEFAULTS = {\n  STYLES: {\n    container: {\n      position: \"fixed\",\n      top: \"0\",\n      left: \"0\",\n      width: \"100%\",\n      height: \"100%\",\n      backgroundColor: \"rgba(0, 0, 0, 0.5)\",\n      backdropFilter: \"blur(10px)\",\n      display: \"flex\",\n      justifyContent: \"center\",\n      alignItems: \"center\",\n      zIndex: \"1000\"\n    },\n    content: {\n      backgroundColor: \"white\",\n      padding: \"20px\",\n      borderRadius: \"8px\",\n      width: \"80%\",\n      maxWidth: \"80%\",\n      position: \"relative\"\n    },\n    iframe: {\n      width: \"100%\",\n      height: \"80vh\",\n      border: \"none\",\n      borderRadius: \"4px\"\n    }\n  },\n  SANDBOX: \"allow-scripts allow-same-origin\",\n  ALLOW: \"camera; microphone\"\n};\n\n// src/index.ts\nvar ModalPopup = class {\n  // private flags: Set<string>;\n  constructor(cfg) {\n    this.modalUrl = cfg.url || null;\n    this.onClose = cfg.onClose || (() => {\n    });\n    this.onOpen = cfg.onOpen || (() => {\n    });\n    this.modalElementMap = /* @__PURE__ */ new WeakMap();\n    this.cfg = cfg;\n    function debounce(func, wait) {\n      let timeout;\n      return function(...args) {\n        clearTimeout(timeout);\n        timeout = setTimeout(() => func.apply(this, args), wait);\n      };\n    }\n    if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n      window.addEventListener(\n        \"beforeunload\",\n        debounce(() => {\n          window.closePopup?.();\n        }, 300),\n        { once: true }\n      );\n    }\n  }\n  // private handleMessage(event: MessageEvent): void {\n  //     try {\n  //         if (this.flags.has(event.data)) {\n  //             this.closePopup();\n  //         }\n  //     } catch (err) {\n  //         console.error('Error handling message event:', err);\n  //     }\n  // }\n  /**\n   * Constructs a URL by replacing path parameters and appending query parameters.\n   *\n   * @param pathParams - An object containing key-value pairs to replace path placeholders in the URL.\n   * @param queryParams - An object containing key-value pairs to be appended as query parameters.\n   * @returns The constructed URL with path and query parameters.\n   * @throws Error if the base URL is not set.\n   */\n  buildUrl(pathParams, queryParams) {\n    if (!this.modalUrl) {\n      throw new Error(\"URL is required.\");\n    }\n    const validateParams = (params2) => {\n      for (const value of Object.values(params2)) {\n        if (/[^a-zA-Z0-9-_]/.test(value)) {\n          throw new Error(\"Invalid characters in URL parameters.\");\n        }\n      }\n    };\n    validateParams(pathParams);\n    validateParams(queryParams);\n    let url = this.modalUrl;\n    for (const [key, value] of Object.entries(pathParams)) {\n      url = url.replace(`:${key}`, value);\n    }\n    const params = new URLSearchParams(queryParams);\n    return `${url}?${params.toString()}`;\n  }\n  /**\n   * Opens a modal popup by constructing a URL with the given path and query parameters.\n   * If a modal is already open, it logs a warning and exits.\n   * Throws an error if executed outside a browser environment.\n   *\n   * @param pathParams - An object containing key-value pairs to replace path placeholders in the URL.\n   * @param queryParams - An object containing key-value pairs to be appended as query parameters.\n   * @throws Error if not in a browser environment.\n   */\n  openPopup(pathParams = {}, queryParams = {}) {\n    try {\n      if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n        throw new Error(\"ModalPopup can only be used in a browser environment.\");\n      }\n      if (this.modalElementMap.has(this)) {\n        console.warn(\"A modal is already open.\");\n        return;\n      }\n      const url = this.buildUrl(pathParams, queryParams);\n      const modalElement = this.createModalElement(url);\n      this.modalElementMap.set(this, modalElement);\n      document.body.appendChild(modalElement);\n      this.onOpen();\n    } catch (error) {\n      console.error(\"Failed to open popup:\", error);\n    }\n  }\n  /**\n   * Closes the currently open modal popup by removing it from the DOM.\n   * Sets the modal element to null and triggers the onClose callback.\n   */\n  closePopup() {\n    const modalElement = this.modalElementMap.get(this);\n    if (modalElement) {\n      document.body.removeChild(modalElement);\n      this.modalElementMap.delete(this);\n    } else {\n      console.warn(\"No modal found for this instance.\");\n    }\n    this.onClose();\n  }\n  /**\n   * Represents a modal popup that can be opened and closed within a browser environment.\n   * The modal is configured using a `ModalPopupConfig` object, which specifies the URL,\n   * callbacks for open and close events, and optional styles. The modal content is loaded\n   * in an iframe, and the modal can be closed by clicking outside the content or on a close button.\n   * \n   * The class ensures that only one modal is open at a time and provides methods to build\n   * URLs with path and query parameters. It also handles cleanup before page reload.\n   */\n  applyStyles(element, styles) {\n    for (const [key, value] of Object.entries(styles)) {\n      element.style[key] = value;\n    }\n  }\n  /**\n   * Creates and returns a modal element containing an iframe with the specified URL.\n   * The modal includes a close button and is styled to cover the entire viewport.\n   * Clicking outside the modal content or on the close button will close the modal.\n   *\n   * @param url - The URL to be loaded in the iframe within the modal.\n   * @returns The constructed modal container element.\n   */\n  createModalElement(url) {\n    const containerStyles = Object.assign({}, DEFAULTS.STYLES.container, this.cfg.styles?.container);\n    const contentStyles = Object.assign({}, DEFAULTS.STYLES.content, this.cfg.styles?.content);\n    const iframeStyles = Object.assign({}, DEFAULTS.STYLES.iframe, this.cfg.styles?.iframe);\n    const modalContainer = document.createElement(\"div\");\n    this.applyStyles(modalContainer, containerStyles);\n    const modalContent = document.createElement(\"div\");\n    this.applyStyles(modalContent, contentStyles);\n    const closeButton = document.createElement(\"button\");\n    closeButton.textContent = \"\\xD7\";\n    closeButton.style.cssText = `\n            position: absolute !important;\n            top: 10px !important;\n            right: 10px !important;\n            background: none !important;\n            border: none !important;\n            font-size: 20px !important;\n            cursor: pointer !important;\n        `;\n    closeButton.setAttribute(\"aria-label\", \"Close\");\n    const iframe = document.createElement(\"iframe\");\n    iframe.src = url;\n    iframe.setAttribute(\"sandbox\", this.cfg.sandbox || DEFAULTS.SANDBOX);\n    iframe.setAttribute(\"allow\", this.cfg.allow || DEFAULTS.ALLOW);\n    this.applyStyles(iframe, iframeStyles);\n    iframe.addEventListener(\"error\", () => {\n      const errorMessage = document.createElement(\"div\");\n      errorMessage.textContent = \"Failed to load content.\";\n      modalContent.appendChild(errorMessage);\n      console.error(\"Failed to load iframe content from URL:\", url);\n    });\n    modalContent.appendChild(closeButton);\n    modalContent.appendChild(iframe);\n    modalContainer.appendChild(modalContent);\n    modalContainer.addEventListener(\"click\", (event) => {\n      if (event.target === modalContainer) {\n        this.closePopup();\n      }\n    });\n    closeButton.addEventListener(\"click\", () => this.closePopup());\n    return modalContainer;\n  }\n};\nfunction createModalPopup(config) {\n  return new ModalPopup(config);\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n  createModalPopup\n});\n"]}