{"version":3,"file":"checkbox_controller-BxicJXni.js","sources":["../../../app/javascript/controllers/property/checkbox_controller.js"],"sourcesContent":["import PropertyController from \"../property_controller\"\n\nimport { useBatchUpdateNotifiers } from '../mixins/useBatchUpdateNotifiers'\n\nexport default class extends PropertyController {\n static targets = [\"deleteButton\", \"checkbox\"]\n\n initialize() {\n this.checkboxTarget.indeterminate = this.checkboxTarget.hasAttribute('data-indeterminate')\n super.initialize()\n }\n\n connect() {\n useBatchUpdateNotifiers(this, {\n onBatchUpdateAbortion: () => this.restore(),\n onBatchUpdateCancellation: () => {\n if(this.blockedAnchor) {\n return this.blockedAnchor.click()\n }\n\n this.restore()\n }\n })\n\n super.connect()\n }\n\n saveChanges(e) {\n if(\n !this.isViewable\n || this.element.contains(e.target)\n || e.target.getAttribute('data-audience--contact-target') === 'checkbox'\n || e.target.closest('dialog')\n || this.isBlockedAnchor(e)\n ) return\n\n if(this.inBatchUpdateMode() && !this.checkboxTarget.indeterminate) {\n if(e.target.closest('a') || e.target.tagName === 'A') {\n e.preventDefault()\n e.stopPropagation()\n\n this.blockedAnchor = e.target.closest('a') || e.target\n }\n\n this.requestBatchUpdateConfirmation()\n }\n }\n\n onCheckboxValueChange(e) {\n if(this.inBatchUpdateMode()) {\n return;\n }\n\n if(e.target.checked) {\n this.formTarget.requestSubmit()\n } else if(this.persistedValue) {\n this.deleteButtonTarget.click()\n }\n }\n\n restore() {\n this.checkboxTarget.checked = false\n this.checkboxTarget.indeterminate = this.checkboxTarget.hasAttribute('data-indeterminate')\n }\n\n get isViewable() {\n return !(this.element.closest('[data-audience--batch-update-target=\"pane\"].hidden') || this.element.closest('[data-audience--content-target=\"detailPane\"].hidden'))\n }\n\n getValueForBatch() {\n return this.checkboxTarget.checked\n }\n}\n"],"names":["checkbox_controller","PropertyController","useBatchUpdateNotifiers","e","__publicField"],"mappings":"oRAIe,MAAKA,UAASC,CAAmB,CAG9C,YAAa,CACX,KAAK,eAAe,cAAgB,KAAK,eAAe,aAAa,oBAAoB,EACzF,MAAM,WAAU,CACpB,CAEE,SAAU,CACRC,EAAwB,KAAM,CAC5B,sBAAuB,IAAM,KAAK,QAAS,EAC3C,0BAA2B,IAAM,CAC/B,GAAG,KAAK,cACN,OAAO,KAAK,cAAc,MAAK,EAGjC,KAAK,QAAO,CACpB,CACK,CAAA,EAED,MAAM,QAAO,CACjB,CAEE,YAAYC,EAAG,CAEX,CAAC,KAAK,YACH,KAAK,QAAQ,SAASA,EAAE,MAAM,GAC9BA,EAAE,OAAO,aAAa,+BAA+B,IAAM,YAC3DA,EAAE,OAAO,QAAQ,QAAQ,GACzB,KAAK,gBAAgBA,CAAC,GAGxB,KAAK,kBAAmB,GAAI,CAAC,KAAK,eAAe,iBAC/CA,EAAE,OAAO,QAAQ,GAAG,GAAKA,EAAE,OAAO,UAAY,OAC/CA,EAAE,eAAc,EAChBA,EAAE,gBAAe,EAEjB,KAAK,cAAgBA,EAAE,OAAO,QAAQ,GAAG,GAAKA,EAAE,QAGlD,KAAK,+BAA8B,EAEzC,CAEE,sBAAsBA,EAAG,CACpB,KAAK,sBAILA,EAAE,OAAO,QACV,KAAK,WAAW,cAAa,EACrB,KAAK,gBACb,KAAK,mBAAmB,MAAK,EAEnC,CAEE,SAAU,CACR,KAAK,eAAe,QAAU,GAC9B,KAAK,eAAe,cAAgB,KAAK,eAAe,aAAa,oBAAoB,CAC7F,CAEE,IAAI,YAAa,CACf,MAAO,EAAE,KAAK,QAAQ,QAAQ,oDAAoD,GAAK,KAAK,QAAQ,QAAQ,qDAAqD,EACrK,CAEE,kBAAmB,CACjB,OAAO,KAAK,eAAe,OAC/B,CACA,CAnEEC,EADkBJ,EACX,UAAU,CAAC,eAAgB,UAAU"}