{"version":3,"file":"dialog_controller-Bn-TljmS.js","sources":["../../../app/javascript/controllers/dialog_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\nexport default class Dialog extends Controller {\n static targets = [\"dialog\"];\n\n static values = {\n open: Boolean,\n id: String\n };\n\n initialize() {\n this.forceClose = this.forceClose.bind(this);\n }\n\n connect() {\n this.updateVisibility();\n\n document.addEventListener(\"turbo:before-render\", this.forceClose);\n document.addEventListener(\"dialog:open\", this.handleOpen.bind(this));\n document.addEventListener(\"dialog:close\", this.handleClose.bind(this));\n }\n\n disconnect() {\n document.removeEventListener(\"turbo:before-render\", this.forceClose);\n document.removeEventListener(\"dialog:open\", this.handleOpen.bind(this));\n document.removeEventListener(\"dialog:close\", this.handleClose.bind(this));\n }\n\n updateVisibility() {\n if (this.openValue) {\n this.open();\n }\n }\n\n handleOpen(event) {\n if (event.detail.id === this.idValue) {\n this.open();\n }\n }\n\n handleClose(event) {\n if (event.detail.id === this.idValue) {\n this.close();\n }\n }\n\n open() {\n this.dialogTarget.showModal();\n }\n\n close() {\n this.dialogTarget.setAttribute(\"closing\", \"\");\n\n Promise.all(\n this.dialogTarget.getAnimations().map(animation => animation.finished)\n )\n .then(() => {\n this.dialogTarget.removeAttribute(\"closing\");\n this.dialogTarget.close();\n })\n .catch(() => {\n this.dialogTarget.removeAttribute(\"closing\");\n this.dialogTarget.close();\n });\n }\n\n backdropClose(event) {\n if (event.target === this.dialogTarget) {\n this.close();\n }\n }\n\n forceClose() {\n this.dialogTarget.close();\n }\n}\n"],"names":["Dialog","Controller","event","animation","__publicField"],"mappings":"4VAEe,MAAMA,UAAeC,CAAW,CAQ7C,YAAa,CACX,KAAK,WAAa,KAAK,WAAW,KAAK,IAAI,CAC/C,CAEE,SAAU,CACR,KAAK,iBAAkB,EAEvB,SAAS,iBAAiB,sBAAuB,KAAK,UAAU,EAChE,SAAS,iBAAiB,cAAe,KAAK,WAAW,KAAK,IAAI,CAAC,EACnE,SAAS,iBAAiB,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