{"version":3,"file":"section-picker-modal.element-CWp9mISy.js","sources":["../../../src/packages/core/section/section-picker-modal/section-picker-modal.element.ts"],"sourcesContent":["import type { UmbSectionPickerModalData, UmbSectionPickerModalValue } from './section-picker-modal.token.js';\nimport { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';\nimport { UmbSelectionManager } from '@umbraco-cms/backoffice/utils';\nimport type { ManifestSection } from '@umbraco-cms/backoffice/extension-registry';\nimport { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';\nimport { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';\n\n@customElement('umb-section-picker-modal')\nexport class UmbSectionPickerModalElement extends UmbModalBaseElement<\n\tUmbSectionPickerModalData,\n\tUmbSectionPickerModalValue\n> {\n\t@state()\n\tprivate _sections: Array = [];\n\n\t@state()\n\tprivate _selectable = false;\n\n\t#selectionManager = new UmbSelectionManager(this);\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.#selectionManager.setSelectable(true);\n\t\tthis.observe(this.#selectionManager.selectable, (selectable) => (this._selectable = selectable), null);\n\n\t\tthis.observe(\n\t\t\tumbExtensionsRegistry.byType('section'),\n\t\t\t(sections: Array) => (this._sections = sections),\n\t\t\tnull,\n\t\t);\n\t}\n\n\toverride connectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.#selectionManager.setMultiple(this.data?.multiple ?? false);\n\t\tthis.#selectionManager.setSelection(this.value?.selection ?? []);\n\t}\n\n\t#submit() {\n\t\tthis.value = { selection: this.#selectionManager.getSelection() };\n\t\tthis._submitModal();\n\t}\n\n\toverride render() {\n\t\treturn html`\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t${this._sections.map(\n\t\t\t\t\t\t(item) => html`\n\t\t\t\t\t\t\t this.#selectionManager.select(item.alias)}\n\t\t\t\t\t\t\t\t@deselected=${() => this.#selectionManager.deselect(item.alias)}>\n\t\t\t\t\t\t`,\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t`;\n\t}\n}\n\nexport default UmbSectionPickerModalElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-section-picker-modal': UmbSectionPickerModalElement;\n\t}\n}\n"],"names":["_selectionManager","_UmbSectionPickerModalElement_instances","submit_fn","UmbSectionPickerModalElement","UmbModalBaseElement","__privateAdd","UmbSelectionManager","__privateGet","selectable","umbExtensionsRegistry","sections","html","item","__privateMethod","__decorateClass","state","customElement","UmbSectionPickerModalElement$1"],"mappings":";;;;;;;;;;+TAAAA,GAAAC,GAAAC;AAQa,IAAAC,IAAN,cAA2CC,EAGhD;AAAA,EASD,cAAc;AACP,aAbDC,EAAA,MAAAJ,CAAA,GAKN,KAAQ,YAAoC,IAG5C,KAAQ,cAAc,IAEFI,EAAA,MAAAL,GAAA,IAAIM,EAAoB,IAAI,CAAA,GAI1CC,EAAA,MAAAP,CAAA,EAAkB,cAAc,EAAI,GACpC,KAAA,QAAQO,QAAKP,CAAkB,EAAA,YAAY,CAACQ,MAAgB,KAAK,cAAcA,GAAa,IAAI,GAEhG,KAAA;AAAA,MACJC,EAAsB,OAAO,SAAS;AAAA,MACtC,CAACC,MAAsC,KAAK,YAAYA;AAAA,MACxD;AAAA,IAAA;AAAA,EAEF;AAAA,EAES,oBAA0B;AAClC,UAAM,kBAAkB,GACxBH,EAAA,MAAKP,CAAkB,EAAA,YAAY,KAAK,MAAM,YAAY,EAAK,GAC/DO,EAAA,MAAKP,GAAkB,aAAa,KAAK,OAAO,aAAa,CAAA,CAAE;AAAA,EAChE;AAAA,EAOS,SAAS;AACV,WAAAW;AAAA;AAAA;AAAA,OAGF,KAAK,UAAU;AAAA,MAChB,CAACC,MAASD;AAAA;AAAA,gBAEA,KAAK,SAAS,OAAOC,EAAK,KAAK,KAAK,CAAC;AAAA,sBAC/B,KAAK,WAAW;AAAA,oBAClBL,EAAK,MAAAP,CAAA,EAAkB,WAAWY,EAAK,K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