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AY,iBAAiB,CAAE,SAAS,IAAQ,MAAK,GACjC,WAAhB,EAAG,UAAqD,WAA5B,EAAG,aAAa,WAC/C,IAEV,CAWA,GAAiB,GAEf,IAAM,EAAW,KAEjB,GAAI,OAAO,UAAU,eAAe,KAAK,EAAU,GAAO,CACxD,IAAM,EAAQ,EAAS,UAChB,EAAS,GAChB,EAAS,GAAQ,CACnB,CACF,CAWA,0BAAO,CAAoB,EAAc,oBAC5B,OAAW,MAAgB,OAAO,eAAe,IAAI,IAC9D,OAAO,eAAe,OAAO,EAAa,EAE9C,UACF","file":"/npm/@georapbox/web-share-element@3.1.1/dist/web-share.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/@georapbox/web-share-element@3.1.1/dist/web-share.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// @ts-check\n\n/**\n * Represents a value that may be of type T, or null.\n *\n * @template T\n * @typedef {T | null} Nullable\n */\n\n/**\n * Represents the data to share.\n *\n * @typedef {Object} ShareData\n * @property {string} [url] - The URL to share.\n * @property {string} [title] - The title to share.\n * @property {string} [text] - The text to share.\n * @property {File[]} [files] - The files to share.\n */\n\nconst styles = /* css */ `\n  :host {\n    display: inline-block;\n  }\n`;\n\nconst template = document.createElement('template');\n\ntemplate.innerHTML = /* html */ `\n  <style>${styles}</style>\n  <slot name=\"button\"><button type=\"button\" part=\"button\"><slot name=\"button-content\">Share</slot></button></slot>\n`;\n\n/**\n * @summary A custom element that provides a button to share content.\n * @documentation https://github.com/georapbox/web-share-element#readme\n *\n * @tagname web-share - This is the default tag name, unless overridden by the `defineCustomElement` method.\n *\n * @property {boolean} disabled - Indicates whether the button is disabled.\n * @property {string} shareUrl - The URL to share.\n * @property {string} shareTitle - The title to share.\n * @property {string} shareText - The text to share.\n * @property {File[]} shareFiles - The files to share.\n *\n * @attribute {boolean} disabled - Reflects the disabled property.\n * @attribute {string} share-url - Reflects the shareUrl property.\n * @attribute {string} share-title - Reflects the shareTitle property.\n * @attribute {string} share-text - Reflects the shareText property.\n *\n * @slot button - The button to share content.\n * @slot button-content - The content of the button to share content.\n *\n * @csspart button - The button to share content.\n * @csspart button--disabled - The button to share content when disabled.\n *\n * @event web-share:success - Fired when the share operation is successful.\n * @event web-share:abort - Fired when the share operation is aborted.\n * @event web-share:error - Fired when the share operation fails.\n *\n * @method defineCustomElement - Static method. Defines the custom element with the given name.\n * @method share - Instance method. Shares the shareable data taken from the element's properties.\n */\nclass WebShare extends HTMLElement {\n  /** @type {Nullable<HTMLSlotElement>} */\n  #buttonSlot;\n\n  /** @type {Nullable<Element>} */\n  #buttonEl;\n\n  /** @type {File[]} */\n  #files = [];\n\n  constructor() {\n    super();\n\n    if (!this.shadowRoot) {\n      const shadowRoot = this.attachShadow({ mode: 'open', delegatesFocus: true });\n      shadowRoot.appendChild(template.content.cloneNode(true));\n    }\n\n    this.#buttonSlot = this.shadowRoot?.querySelector('slot[name=\"button\"]') || null;\n    this.#buttonEl = this.#getButton();\n  }\n\n  static get observedAttributes() {\n    return ['disabled'];\n  }\n\n  /**\n   * Lifecycle method that is called when attributes are changed, added, removed, or replaced.\n   *\n   * @param {string} name - The name of the attribute.\n   * @param {string} oldValue - The old value of the attribute.\n   * @param {string} newValue - The new value of the attribute.\n   */\n  attributeChangedCallback(name, oldValue, newValue) {\n    if (name === 'disabled' && oldValue !== newValue && this.#buttonEl) {\n      this.#buttonEl.toggleAttribute('disabled', this.disabled);\n      this.#buttonEl.setAttribute('aria-disabled', this.disabled.toString());\n\n      if (this.#buttonEl.part && this.#buttonEl.part.contains('button')) {\n        this.#buttonEl.part.toggle('button--disabled', this.disabled);\n      }\n    }\n  }\n\n  /**\n   * Lifecycle method that is called when the element is added to the DOM.\n   */\n  connectedCallback() {\n    this.#upgradeProperty('shareUrl');\n    this.#upgradeProperty('shareTitle');\n    this.#upgradeProperty('shareText');\n    this.#upgradeProperty('shareFiles');\n    this.#upgradeProperty('disabled');\n\n    this.#buttonSlot?.addEventListener('slotchange', this.#handleSlotChange);\n    this.#buttonEl?.addEventListener('click', this.#handleClick);\n  }\n\n  /**\n   * Lifecycle method that is called when the element is removed from the DOM.\n   */\n  disconnectedCallback() {\n    this.#buttonSlot?.removeEventListener('slotchange', this.#handleSlotChange);\n    this.#buttonEl?.removeEventListener('click', this.#handleClick);\n  }\n\n  /**\n   * @type {boolean} - Indicates whether the button is disabled.\n   * @default false\n   * @attribute disabled - Reflects the disabled property.\n   */\n  get disabled() {\n    return this.hasAttribute('disabled');\n  }\n\n  set disabled(value) {\n    this.toggleAttribute('disabled', !!value);\n  }\n\n  /**\n   * @type {string} - The URL to share.\n   * @attribute share-url - Reflects the shareUrl property.\n   */\n  get shareUrl() {\n    return this.getAttribute('share-url') || '';\n  }\n\n  set shareUrl(value) {\n    this.setAttribute('share-url', value);\n  }\n\n  /**\n   * @type {string} - The title to share.\n   * @attribute share-title - Reflects the shareTitle property.\n   */\n  get shareTitle() {\n    return this.getAttribute('share-title') || '';\n  }\n\n  set shareTitle(value) {\n    this.setAttribute('share-title', value);\n  }\n\n  /**\n   * @type {string} - The text to share.\n   * @attribute share-text - Reflects the shareText property.\n   */\n  get shareText() {\n    return this.getAttribute('share-text') || '';\n  }\n\n  set shareText(value) {\n    this.setAttribute('share-text', value);\n  }\n\n  /**\n   * @type {File[]} - The files to share.\n   */\n  get shareFiles() {\n    return this.#files;\n  }\n\n  set shareFiles(value) {\n    if (Array.isArray(value) && value.length > 0) {\n      this.#files = value;\n    }\n  }\n\n  /**\n   * Shares the shareable data taken from the element's properties.\n   *\n   * @returns {Promise<void>} - A promise that resolves when the share operation is complete.\n   */\n  async share() {\n    if (this.disabled) {\n      return;\n    }\n\n    try {\n      /** @type {ShareData} */\n      const shareData = {};\n\n      if (this.shareUrl) {\n        shareData.url = this.shareUrl;\n      }\n\n      if (this.shareTitle) {\n        shareData.title = this.shareTitle;\n      }\n\n      if (this.shareText) {\n        shareData.text = this.shareText;\n      }\n\n      if (\n        Array.isArray(this.shareFiles) &&\n        this.shareFiles.length > 0 &&\n        navigator.canShare &&\n        navigator.canShare({ files: this.shareFiles })\n      ) {\n        shareData.files = this.shareFiles;\n      }\n\n      await navigator.share(shareData);\n\n      this.dispatchEvent(\n        new CustomEvent('web-share:success', {\n          bubbles: true,\n          composed: true,\n          detail: { shareData }\n        })\n      );\n    } catch (error) {\n      if (error instanceof Error && error.name === 'AbortError') {\n        this.dispatchEvent(\n          new CustomEvent('web-share:abort', {\n            bubbles: true,\n            composed: true,\n            detail: { error }\n          })\n        );\n\n        return;\n      }\n\n      this.dispatchEvent(\n        new CustomEvent('web-share:error', {\n          bubbles: true,\n          composed: true,\n          detail: { error }\n        })\n      );\n    }\n  }\n\n  /**\n   * Handles the click event on the button.\n   *\n   * @param {any} evt - The event object.\n   */\n  #handleClick = evt => {\n    evt.preventDefault();\n\n    if (this.disabled) {\n      return;\n    }\n\n    this.share();\n  };\n\n  /**\n   * Handles the slotchange event on the button slot.\n   *\n   * @param {any} evt - The event object.\n   */\n  #handleSlotChange = evt => {\n    if (evt.target && evt.target.name === 'button') {\n      this.#buttonEl?.removeEventListener('click', this.#handleClick);\n      this.#buttonEl = this.#getButton();\n\n      if (this.#buttonEl) {\n        this.#buttonEl.addEventListener('click', this.#handleClick);\n\n        if (this.#buttonEl.nodeName !== 'BUTTON' && !this.#buttonEl.hasAttribute('role')) {\n          this.#buttonEl.setAttribute('role', 'button');\n        }\n      }\n    }\n  };\n\n  /**\n   * Returns the button element from the button slot.\n   *\n   * @returns {Nullable<Element>} - The button element.\n   */\n  #getButton() {\n    if (!this.#buttonSlot) {\n      return null;\n    }\n\n    return (\n      this.#buttonSlot.assignedElements({ flatten: true }).find(el => {\n        return el.nodeName === 'BUTTON' || el.getAttribute('slot') === 'button';\n      }) || null\n    );\n  }\n\n  /**\n   * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n   * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n   * property and the instance property would prevent the class property setter from ever being called.\n   *\n   * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n   *\n   * @param {'shareUrl' | 'shareTitle' | 'shareText' | 'shareFiles' | 'disabled'} prop - The property name to upgrade.\n   */\n  #upgradeProperty(prop) {\n    /** @type {any} */\n    const instance = this;\n\n    if (Object.prototype.hasOwnProperty.call(instance, prop)) {\n      const value = instance[prop];\n      delete instance[prop];\n      instance[prop] = value;\n    }\n  }\n\n  /**\n   * Defines a custom element with the given name.\n   * The name must contain a dash (-).\n   *\n   * @param {string} [elementName='web-share'] - The name of the custom element.\n   * @example\n   *\n   * ClipboardCopy.defineCustomElement('my-web-share');\n   */\n  static defineCustomElement(elementName = 'web-share') {\n    if (typeof window !== 'undefined' && !window.customElements.get(elementName)) {\n      window.customElements.define(elementName, WebShare);\n    }\n  }\n}\n\nexport { WebShare };\n"]}