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,OACL,OAAQ,cAGR","file":"/npm/@symfony/ux-notify@2.31.0/dist/controller.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@symfony/ux-notify@2.31.0/dist/controller.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// src/controller.ts\nimport { Controller } from \"@hotwired/stimulus\";\nvar controller_default = class extends Controller {\n  constructor() {\n    super(...arguments);\n    this.eventSources = [];\n    this.listeners = /* @__PURE__ */ new WeakMap();\n  }\n  initialize() {\n    const errorMessages = [];\n    if (!this.hasHubValue) errorMessages.push('A \"hub\" value pointing to the Mercure hub must be provided.');\n    if (!this.hasTopicsValue) errorMessages.push('A \"topics\" value must be provided.');\n    if (errorMessages.length) throw new Error(errorMessages.join(\" \"));\n    this.eventSources = this.topicsValue.map((topic) => {\n      const u = new URL(this.hubValue);\n      u.searchParams.append(\"topic\", topic);\n      return new EventSource(u);\n    });\n  }\n  connect() {\n    if (!(\"Notification\" in window)) {\n      console.warn(\"This browser does not support desktop notifications.\");\n      return;\n    }\n    this.eventSources.forEach((eventSource) => {\n      const listener = (event) => {\n        const { summary, content } = JSON.parse(event.data);\n        this._notify(summary, content);\n      };\n      eventSource.addEventListener(\"message\", listener);\n      this.listeners.set(eventSource, listener);\n    });\n    this.dispatchEvent(\"connect\", { eventSources: this.eventSources });\n  }\n  disconnect() {\n    this.eventSources.forEach((eventSource) => {\n      const listener = this.listeners.get(eventSource);\n      if (listener) {\n        eventSource.removeEventListener(\"message\", listener);\n      }\n      eventSource.close();\n    });\n    this.eventSources = [];\n  }\n  _notify(title, options) {\n    if (!title) return;\n    if (\"granted\" === Notification.permission) {\n      new Notification(title, options);\n      return;\n    }\n    if (\"denied\" !== Notification.permission) {\n      Notification.requestPermission().then((permission) => {\n        if (\"granted\" === permission) {\n          new Notification(title, options);\n        }\n      });\n    }\n  }\n  dispatchEvent(name, payload) {\n    this.dispatch(name, { detail: payload, prefix: \"notify\" });\n  }\n};\ncontroller_default.values = {\n  hub: String,\n  topics: Array\n};\nexport {\n  controller_default as default\n};\n"]}