1import{_ as r,a,c,b as E}from"./chunk-vendor-di.Bh23gdA.js";import{P as T,e as d,y as ve,G as fe,k as be,w as D,$ as v,t as ee,U as L,S as Oe,b as B,d as M,c as ge}from"./chunk-vendor-lit.NvY0u02.js";import{p as I}from"./chunk-phoenix_custom_element.-3oJuZO.js";import{a as G,b as g,c as te,d as re,e as ae,f as Y,g as $e,S as m}from"./chunk-select_utils.BhqqJnk.js";import{B as ce}from"./chunk-btn_controller.BPcEEeZ.js";import{O as V}from"./chunk-observer.oe4_irb.js";import{H as Ce}from"./chunk-icon.DseOU9r.js";import{C as me}from"./chunk-context_consumer_controller.DQ84A7A.js";import{C as ye}from"./chunk-context_provider_controller.CCbkLM7.js";import{v as Se}from"./chunk-v4.FWzwXvE.js";import{c as Ee,b as Ae,a as we,H as Le}from"./chunk-dropdown.DlBsJyX.js";import{c as Te}from"./chunk-icon_constants.BVm6Vwv.js";import{d as Ie}from"./chunk-vendor-lodash.CWHFt7Z.js";import{B as se}from"./chunk-behavior_subject.BGn-8a7.js";import"./chunk-keystrokes_controller.BSiCZ0Y.js";import"./chunk-index.D5AUA1V.js";import"./chunk-subject.nuVoBpB.js";import"./chunk-relative_position_controller_constants.D8T_ePx.js";import"./chunk-portal_constants.uZUnw1k.js";import"./chunk-backdrop_controller.BQhgTTX.js";import"./chunk-backdrop_constants.5bk4eBT.js";import"./chunk-click_outside_controller.DmGcU-e.js";import"./chunk-relative_position_controller.Dk2rlFc.js";const ie="select-option",de={selectOption:ie,selectOptionContent:`${ie}__content`};let $=class extends T{constructor(){super(...arguments),this._dispatchClickedEvent=()=>{this.disabled&&!this.clickable||this.emitCustomEvent(G.clicked,{detail:{$option:this}})}}connectedCallback(){super.connectedCallback(),this._btnController||(this._btnController=new ce(this,this._dispatchClickedEvent)),this.classList.add(de.selectOption),this.setAttribute("role","option"),this._setupEvents()}_setupEvents(){this.addEventListener("click",this._dispatchClickedEvent)}updated(e){super.updated(e),e.has("selected")&&(this.selected?this._addSelectedIcon():this._removeSelectedIcon()),(e.has("inactive")||e.has("hidden")||e.has("disabled"))&&this._dispatchSelectUpdated()}_dispatchSelectUpdated(){this.emitCustomEvent(G.updated,{detail:{$option:this}})}_addSelectedIcon(){this._$checkedIcon=document.createElement("h-icon"),this._$checkedIcon.setAttribute("icon-name","icon-check"),this.append(this._$checkedIcon)}_removeSelectedIcon(){var e;(e=this._$checkedIcon)===null||e===void 0||e.remove(),this._$checkedIcon=void 0}};r([d({type:String,reflect:!0}),a("design:type",String)],$.prototype,"value",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],$.prototype,"selected",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],$.prototype,"disabled",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],$.prototype,"hidden",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],$.prototype,"inactive",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],$.prototype,"clickable",void 0);$=r([I(g.option)],$);let J=class extends T{connectedCallback(){super.connectedCallback(),this.classList.add(de.selectOptionContent)}};J=r([I(g.optionContent)],J);let Z=class extends T{constructor(){super(),this._dispatchClickedEvent=({detail:e})=>{this.emitCustomEvent(te.optionClicked,{detail:{$option:e.$option}})},this._dispatchUpdatedEvent=({detail:e})=>{this.emitCustomEvent(te.optionUpdated,{detail:{$option:e.$option}})},this.setAttribute("role","listbox"),this.addEventListener(G.clicked,this._dispatchClickedEvent),this.addEventListener(G.updated,this._dispatchUpdatedEvent)}};Z=r([I(g.options),a("design:paramtypes",[])],Z);const j={isMultiselect:"isMultiselect",selectedOptions$:"selectedOptions$"},N={content:"content",toggler:"toggler"},oe={select:"select-one",multiple:"select-multiple"},he={deselectOption:"deselect"},xe=6,u="select",p={select:u,selectOpened:`${u}_opened`,selectError:`${u}_error`,selectDisabled:`${u}_disabled`,selectWithSearch:`${u}_with-search`,selectSearch:`${u}__search`,selectOptions:`${u}__options`,selectOptionsEmpty:`${u}__options_empty`,selectContent:`${u}__content`,selectContentError:`${u}__content_error`,selectFooter:`${u}__footer`,selectNoResult:`${u}__no-result`,selectSearchedPhrase:`${u}__searched-phrase`,selectCloseMobileButton:`${u}__close-mobile-btn`,selectClearButton:`${u}__clear-btn`,selectCloseButton:`${u}__close-btn`,selectLabel:`${u}__label`},A={NO_RESULTS_FOR:"Brak wyników dla",RESET:"Reset",CHOOSE:"Choose",SEARCH:"Szukaj"};class Ne extends fe{render(e,t){var s;return this._observable!==e&&((s=this.observable)===null||s===void 0||s.unsubscribe(this.observer),this._observable=e,this._render=t,this.isConnected&&this.subscribe(e,t)),be}subscribe(e,t){this.observable=e,this.observer=new V(s=>{this.setValue(typeof t=="function"?t(s):s)}),e.subscribe(this.observer)}disconnected(){var e;(e=this.observable)===null||e===void 0||e.unsubscribe(this.observer)}reconnected(){this.subscribe(this._observable,this._render)}}const pe=ve(Ne),w="select-toggler",y={selectToggler:w,selectTogglerSelected:`${w}_selected`,selectTogglerValues:`${w}__values`,selectTogglerPlaceholder:`${w}__placeholder`,selectTogglerLayout:`${w}__layout`,selectTogglerName:`${w}__name`,selectTogglerAddon:`${w}__addon`};let P=class extends T{constructor(){super(...arguments),this._contextConsumer=new me(this),this._handleSelectedOptionChanged=e=>{e.length?this.classList.add(y.selectTogglerSelected):this.classList.remove(y.selectTogglerSelected)},this._dispatchOptionDeselect=e=>{this.emitCustomEvent(he.deselectOption,{detail:e.value})}}connectedCallback(){super.connectedCallback(),this.setAttribute("slot",N.toggler),this.setAttribute("role","textbox"),this.classList.add(y.selectToggler),this._subscribeOb
1server()}async _subscribeObserver(){this.isMultiselect=await this._contextConsumer.consumeAsync(j.isMultiselect),this.selectedOptions$=await this._contextConsumer.consumeAsync(j.selectedOptions$),this._selectedOptionsObserver=new V(this._handleSelectedOptionChanged),this.selectedOptions$.subscribe(this._selectedOptionsObserver)}_getParsedOptionContent(e){const t=(e.content||"").split(` 2`).map(s=>s.trim()).filter(s=>s.length>0);return{name:t[0]||"",addon:t.slice(1).join(" ")}}_renderTogglerContent(e){const{name:t,addon:s}=this._getParsedOptionContent(e);return v` 3 <div class=${y.selectTogglerLayout}> 4 <span class=${y.selectTogglerName}>${t}</span> 5 ${s?v`<span class=${y.selectTogglerAddon}>${s}</span>`:D} 6 </div> 7 `}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.selectedOptions$)===null||e===void 0||e.unsubscribe(this._selectedOptionsObserver)}render(){if(this.selectedOptions$)return v` 8 ${pe(this.selectedOptions$,e=>{var t;return e.length?v` <ul class=${y.selectTogglerValues}> 9 ${this.isMultiselect?e.map(s=>{const n=this._renderTogglerContent(s);return v` <li> 10 <h-tag @remove=${()=>this._dispatchOptionDeselect(s)}> 11 ${n} 12 <h-tag-remove-button></h-tag-remove-button> 13 </h-tag> 14 </li>`}):v`<li>${this._renderTogglerContent(e[0])}</li>`} 15 </ul>`:v`${(t=this.getSlot(re))!==null&&t!==void 0?t:v`<span class=${y.selectTogglerPlaceholder}>Select</span>`}`})} 16 17 <h-icon icon-name="icon-chevron-down"></h-icon> 18 `}};r([ee(),a("design:type",Object)],P.prototype,"selectedOptions$",void 0);r([ee(),a("design:type",Boolean)],P.prototype,"isMultiselect",void 0);P=r([I(g.toggler)],P);class R{constructor({selected:e=!1,hidden:t=!1,disabled:s=!1,value:n,content:i,inactive:o=!1,isPlaceholder:l=!1}){this.value=n,this.selected=e,this.hidden=t,this.disabled=s,this.content=i,this.inactive=o,this.isPlaceholder=l}static create(e){return new R(e)}}let Q=class extends T{constructor(){super(...arguments),this._dispatchCloseEvent=()=>{this.emitCustomEvent(ae.close)}}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label","close select"),this._btnController||(this._btnController=new ce(this,this._dispatchCloseEvent)),this.addEventListener("click",this._dispatchCloseEvent)}render(){return v`${this.hasSlot(Y)?this.getSlot(Y):v` <h-icon size=${Te.l} icon-name="icon-x"></h-icon>`} `}};Q=r([I(g.closeBtn)],Q);const z="select-search",X={selectSearch:z,selectSearchIcon:`${z}__icon`,selectSearchInput:`${z}__input`};let K=class extends T{constructor(){super(...arguments),this.value="",this._$selectOptions=null,this._handleSearchKeydown=e=>{e.key!=="ArrowDown"&&e.key!=="ArrowUp"||(this._handleFocusOptionOnArrowNavigation(),this._handleDispatchEventOnOptionsList(e))},this._handleDispatchEventOnOptionsList=e=>{var t;const s=new KeyboardEvent("keydown",{key:e.key});(t=this._$selectOptions)===null||t===void 0||t.dispatchEvent(s)},this._handleFocusOptionOnArrowNavigation=()=>{const t=(this._$selectOptions?[...this._$selectOptions.querySelectorAll("h-option")]:[]).filter(o=>!o.getAttribute("inactive")&&!o.getAttribute("disabled")&&!o.hidden),s=t.find(o=>!o.getAttribute("inactive")&&!o.getAttribute("disabled")&&!o.getAttribute("hidden")),i=t.find(o=>o.getAttribute("aria-selected"))||s;i?.focus()},this._handleInputChange=Ie(({target:e})=>{this.value=e.value,this.emitCustomEvent($e.search,{detail:e.value})},200)}connectedCallback(){super.connectedCallback(),this.classList.add(X.selectSearch);const e=this.closest(Ee);this._$selectOptions=e?.querySelector("h-options"),this.addEventListener("keydown",this._handleSearchKeydown)}render(){return v` 19 <h-icon icon-name="icon-search" class=${X.selectSearchIcon}></h-icon> 20 <input 21 class=${X.selectSearchInput} 22 type="text" 23 role="search" 24 .value=${this.value} 25 aria-autocomplete="list" 26 autocomplete="false" 27 placeholder=${this.placeholder}
28 @input=${this._handleInputChange} 29 /> 30 `}};r([d({type:String,reflect:!0}),a("design:type",String)],K.prototype,"value",void 0);r([d({type:String}),a("design:type",String)],K.prototype,"placeholder",void 0);K=r([I(g.search)],K);const ne={vertical:"vertical"};var H,S,O,F,W;class ke{constructor({host:e,$list:t,listItemSelector:s='[role="option"]',orientation:n=ne.vertical}){H.set(this,void 0),S.set(this,void 0),O.set(this,void 0),F.set(this,void 0),W.set(this,void 0),this._handleKeyboardNavigation=i=>{if(c(this,W,"f").find(o=>o===i.key)){this._handleArrowNavigation(i);return}this._handleWriteableCharacter(i)},this._handleArrowNavigation=i=>{i.preventDefault();const{key:o}=i,l=c(this,O,"f").filter(x=>!x.getAttribute("inactive")&&!x.getAttribute("disabled")&&!x.hidden),b=this._findCurrentIndex();let f=o==="ArrowDown"||o==="ArrowRight"?this._getNextOptionIndex():this._getPrevOptionIndex();if(f===void 0&&(f=this._findCurrentIndex()),f===this.currentOptionIndex)return;if(b!==void 0){const x=c(this,O,"f")[b];x&&L.makeUnnavigable(x)}this.currentOptionIndex=f;const k=l[f];k&&(L.makeNavigable(k),k.focus())},this._findCurrentIndex=()=>{const o=c(this,O,"f").filter(l=>!l.getAttribute("inactive")&&!l.getAttribute("disabled")&&!l.hidden).findIndex(l=>l.selected);return o!==-1?o:0},this._handleWriteableCharacter=i=>{var o;const l=(o=c(this,H,"f").$search.value)===null||o===void 0?void 0:o.querySelector('[role="search"]');l&&l?.focus()},this.calculateSelectedOptionIndex=()=>{const i=c(this,O,"f").findIndex(o=>o.selected);this.currentOptionIndex=i!==-1?i:0},E(this,H,e),E(this,S,t),E(this,F,s),E(this,W,n===ne.vertical?["ArrowUp","ArrowDown"]:["ArrowLeft","ArrowRight"]),E(this,O,Array.from(t.querySelectorAll(c(this,F,"f")))),c(this,H,"f").addController(this)}hostConnected(){c(this,S,"f").addEventListener("keydown",this._handleKeyboardNavigation),L.makeNavigable(c(this,S,"f")),c(this,S,"f").addEventListener("focusin",e=>{if(e.target!==c(this,S,"f")||this.currentOptionIndex===void 0)return;const t=c(this,O,"f")[this.currentOptionIndex];L.makeUnnavigable(t),this.currentOptionIndex=void 0}),c(this,O,"f").forEach(e=>L.makeUnnavigable(e))}_getPrevOptionIndex(){if(this.currentOptionIndex===void 0)return;if(this.currentOptionIndex<=0)return this.currentOptionIndex;if(this.currentOptionIndex<=0)return this.currentOptionIndex;const e=c(this,O,"f").filter(s=>!s.getAttribute("inactive")&&!s.getAttribute("disabled")&&!s.hidden);if(e[this.currentOptionIndex-1])return this.currentOptionIndex-1;const t=e.findIndex(s=>s.selected);return t?t-1:this.currentOptionIndex-1}_getNextOptionIndex(){if(this.currentOptionIndex===void 0)return;const e=c(this,O,"f").filter(t=>!t.getAttribute("inactive")&&!t.getAttribute("disabled")&&!t.hidden);if(this.currentOptionIndex===e.length-1)return this.currentOptionIndex;if(this.currentOptionIndex>e.length-1){const t=e.findIndex(s=>s.selected);return t?t+1:0}return this.currentOptionIndex+1}hostDisconnected(){c(this,S,"f").removeEventListener("keydown",this._handleKeyboardNavigation)}}H=new WeakMap,S=new WeakMap,O=new WeakMap,F=new WeakMap,W=new WeakMap;class ue{constructor({host:e}){this.options$=new se([]),this.selectedOptions$=new se([]),this._calculateValuesRelatedToOptions=t=>{const{visibleCount:s,selectedCount:n}=t.reduce((i,o)=>({visibleCount:o.hidden?i.visibleCount:i.visibleCount+1,selectedCount:o.selected?i.selectedCount+1:i.selectedCount}),{visibleCount:0,selectedCount:0});this.visibleOptionsCount=s,this.selectedOptionsCount=n},this.host=e,this.host.addController(this),this._setupComputedStateObserver()}_setupComputedStateObserver(){this._optionsObserver=new V(this._calculateValuesRelatedToOptions),this.options$.subscribe(this._optionsObserver)}toggle(e){e.selected?this.deselect(e):this.select(e)}remove(e){const t=this.options$.getValue();t&&this.options$.notify(t.filter(s=>s.value!==e))}add(e,t){var s;const n=(s=this.options$.getValue())!==null&&s!==void 0?s:[];if(t===void 0){n.push(e),this.options$.notify(n);return}this.options$.notify([...n.slice(0,t-1),e,...n.slice(t-1)])}replace(e){this.options$.notify(e)}deselectAll(){var e;(e=this.options$.getValue())===null||e===void 0||e.forEach(t=>t.selected=!1),this.selectedOptions$.notify([]),this.requestUpdate()}deselect(e){var t;(t=this.options$.getValue())===null||t===void 0||t.forEach(s=>s.selected=!1),this.selectedOptions$.notify([]),this.requestUpdate()}updateOption(e,t){const s=this.getOption(e);s&&(Object.entries(t).forEach(([n,i])=>{s[n]=i}),this.requestUpdate())}filter(e){var t;const s=(t=this.options$.getValue())===null||t===void 0?void 0:t.filter(i=>!i.inactive);if(!s)return;const n=Oe.fuzzySearch(e,s,"content");
30s.forEach(i=>i.hidden=!0),n.forEach(i=>{i.hidden=!1}),this.requestUpdate()}requestUpdate(){const e=this.options$.getValue();e&&(this.options$.notify([...e]),this.host.requestUpdate())}getOption(e){var t;return(t=this.options$.getValue())===null||t===void 0?void 0:t.find(s=>s.value===e)}hostConnected(){this.options$.unsubscribe(this._optionsObserver)}}class Be extends ue{toggle(e){e.selected?this.deselect(e):this.select(e)}select(e){e.selected=!0,this.selectedOptions$.notify(t=>[...t,e]),this.requestUpdate()}deselect(e){e.selected=!1,this.selectedOptions$.notify(t=>t.filter(s=>s.value!==e.value)),this.requestUpdate()}}class Me extends ue{select(e){var t;((t=this.options$.getValue())!==null&&t!==void 0?t:[]).forEach(n=>n.selected=!1),e.selected=!0,this.selectedOptions$.notify([e]),this.requestUpdate()}}class le{static toModel(e){const t=e.querySelector(g.optionContent),s=t?.textContent||t?.innerText,n=e.getAttribute("value");if(n==null)throw new Error("h-option must contain a unique value");if(!s)throw new Error("h-options must contains a h-option-content element inside");return R.create({value:n,disabled:e.hasAttribute("disabled"),hidden:e.hasAttribute("hidden"),inactive:e.hasAttribute("inactive"),content:s,selected:e.hasAttribute("selected"),isPlaceholder:e.hasAttribute("placeholder")})}}var C,q,_e,U;class De{constructor({host:e,$toggler:t,$list:s,listItemSelector:n='[role="option"]'}){C.set(this,void 0),q.set(this,void 0),_e.set(this,void 0),U.set(this,void 0),this._handleKeyboardNavigation=i=>{if(["ArrowUp","ArrowDown"].includes(i.key)){this._openSelect(i);return}if(i.key==="Home"){this._openSelectAndGoToFirstElement(i);return}if(i.key==="End"){this._openSelectAndGoToLastElement(i);return}if(i.altKey||i.shiftKey)return;i.key.length===1&&this._openSelectAndGoToMatchedElement(i)},this._openSelect=i=>{var o;i.preventDefault(),(o=c(this,C,"f").$dropdown.value)===null||o===void 0||o.show()},this._openSelectAndGoToFirstElement=async i=>{var o;i.preventDefault(),await((o=c(this,C,"f").$dropdown.value)===null||o===void 0?void 0:o.show());const l=this._getAvailableOptions()[0];l&&this._navigate(l)},this._openSelectAndGoToLastElement=async i=>{var o;i.preventDefault(),await((o=c(this,C,"f").$dropdown.value)===null||o===void 0?void 0:o.show());const l=this._getAvailableOptions(),b=l[l.length-1];b&&this._navigate(b)},this._openSelectAndGoToMatchedElement=async i=>{var o;i.preventDefault(),await((o=c(this,C,"f").$dropdown.value)===null||o===void 0?void 0:o.show());const l=this._getAvailableOptions().find(b=>{var f;return(f=b.innerText)===null||f===void 0?void 0:f.toLowerCase().startsWith(i.key.toLowerCase())});l&&this._navigate(l)},this._getAvailableOptions=()=>c(this,U,"f").filter(i=>!i.getAttribute("inactive")&&!i.getAttribute("disabled")&&!i.hidden),this._findSelectedIndex=()=>{const i=this._getAvailableOptions().findIndex(o=>o.selected);return i!==-1?i:0},this._navigate=i=>{const o=c(this,U,"f")[this._findSelectedIndex()];L.makeUnnavigable(o);const l=this._getAvailableOptions().findIndex(b=>i.value===b.value);c(this,C,"f").listBoxController.currentOptionIndex=l,L.makeNavigable(i),i.focus()},E(this,C,e),E(this,q,t),E(this,U,Array.from(s.querySelectorAll(n))),c(this,C,"f").addController(this)}hostConnected(){c(this,q,"f").addEventListener("keydown",this._handleKeyboardNavigation)}hostDisconnected(){c(this,q,"f").removeEventListener("keydown",this._handleKeyboardNavigation)}}C=new WeakMap,q=new WeakMap,_e=new WeakMap,U=new WeakMap;let h=class extends T{constructor(){super(),this.multiple=!1,this.opened=!1,this.offset=2,this.searchDisabled=!1,this.type=oe.select,this.noDeselect=!1,this.assistiveTitleId="",this.noPlaceholderOption=!1,this.devCachedSelectOptions=!1,this.translations={},this._selectOptionsId=Se(),this._searchValue="",this._$options=new Map,this.$dropdown=B(),this.$search=B(),this._$optionsList=B(),this._$dropdownContent=B(),this.$dropdownToggler=B(),this._selectContext=new ye(this),this.$placeholder="Select",this._updateOptions=()=>{const t=this._getOptions();this._$options=t.reduce((n,i)=>{const o=i.getAttribute("value");if(o==null)throw Error("Select option must have a value");if(n.has(o))throw Error("Select options must have a unique values.");return n.set(o,i)},new Map);const s=t.map(le.toModel);this._selectController.options$.notify(s),s.length&&this._selectController.selectedOptions$.notify(s.filter(n=>n.selected))},this._getOptions=()=>{let t;if(this.optionsList)if(this.devCachedSelectOptions){if(t=[...this.optionsList].map(s=>m.createHTMLOption(R.create(s))),!this.required&&!this.multiple){const s=this.querySelector("h-option[placeholder]");s&&t.unshift(s)}}else t=this.optionsList.map(s=>m.createHTMLOption(R.create(s)));
30else t=this.hasSlot(N.content)?this.getSlot(N.content).map(s=>s.values[0]).filter(s=>s instanceof $):Array.from(this.querySelectorAll(g.option));return t},this._handleOptionDeselect=t=>{const s=this._selectController.getOption(t.detail);s&&(this._selectController.deselect(s),this._dispatchChangeEvent())},this._updateOptionsView=t=>{t.length<Array.from(this._$options.keys()).length&&this._removeHTMLOptions(t.map(s=>s.value)),t.filter(s=>!s.inactive).forEach((s,n)=>{const{selected:i,value:o}=s,l=this._$options.get(o);if(!l){this._appendNewHTMLOption(s,n+1);return}m.syncHTMLOptionWithModel(s,l),i&&this.updateOptionAriaAttribute(l)})},this._updateLabelAria=t=>{var s;if(!this.$searchLabel||((s=this.$searchLabel.querySelector('[id="value-label"]'))===null||s===void 0||s.remove(),!t.some(o=>!o.isPlaceholder)))return;const i=document.createElement("span");i.id="value-label",i.className="sr-only",i.textContent=t.reduce((o,l)=>o+l.content,""),this.$searchLabel.appendChild(i)},this._handleOptionClicked=({detail:t})=>{t?.$option&&this._selectOption(t.$option.value)},this._handleOptionUpdated=({detail:t})=>{if(!t?.$option)return;const s=t.$option;this._selectController.updateOption(s.value,{inactive:s.inactive,hidden:s.hidden})},this._handleDropdownHidden=()=>{var t,s,n;this._searchValue="",this.opened=!1,(t=this.$dropdownToggler.value)===null||t===void 0||t.setAttribute("aria-activedescendant","");const i=document.activeElement===document.body;(!((s=this._$dropdownContent.value)===null||s===void 0)&&s.contains(document.activeElement)||i)&&((n=this.$dropdownToggler.value)===null||n===void 0||n.focus())},this._manageSelectFocusAria=t=>{var s;const n=t.target;if(!n)return;const i=n.id;i&&((s=this.$dropdownToggler.value)===null||s===void 0||s.setAttribute("aria-activedescendant",i))},this._closeSelect=()=>{var t;this.opened&&((t=this.$dropdown.value)===null||t===void 0||t.hide())},this._clearOptions=()=>{this._selectController.deselectAll(),this._dispatchChangeEvent()},this._dispatchChangeEvent=()=>{this.emitEvent("change")},Array.from(this.querySelectorAll(g.option)).forEach(t=>t.setAttribute("slot",N.content)),this.multiple&&(this.type=oe.multiple)}get selectedIndex(){const e=this._selectController.selectedOptions$.getValue();if(!e||e.length===0)return-1;const t=Array.from(this._$options.values());return this.multiple?m.getFirstIndexSelectedOption(t):m.getLastIndexOfSelectedOption(t)}set selectedIndex(e){const t=Array.from(this._$options.values()).filter(s=>!s.hidden)[e];t?this._selectOption(t.value):this._selectController.deselectAll(),Array.from(this._$options.values()).forEach(s=>this.updateOptionAriaAttribute(s))}get selectedOptions(){var e;return((e=this._selectController.selectedOptions$.getValue())!==null&&e!==void 0?e:[]).filter(s=>s.selected).map(s=>this._$options.get(s.value))}get name(){return this.controlName}get id(){return this.controlId}get options(){return Array.from(this._$options.values())}updated(e){var t,s;super.updated(e),e.has("opened")&&(this.opened?(this.classList.add(p.selectOpened),this.devCachedSelectOptions?this._focusElementAfterSelectOpenedAsync():this._focusElementAfterSelectOpened()):this.classList.remove(p.selectOpened)),e.has("optionsList")&&(this._updateOptions(),this._addPlaceholderOptionIfNeeded()),this._$optionsList.value&&((t=this.listBoxController)===null||t===void 0||t.hostDisconnected(),this.listBoxController=new ke({host:this,$list:this._$optionsList.value})),this.listBoxController&&this.listBoxController.calculateSelectedOptionIndex(),this._$optionsList.value&&this.$dropdownToggler.value&&((s=this._selectTogglerKeyboardController)===null||s===void 0||s.hostDisconnected(),this._selectTogglerKeyboardController=new De({host:this,$toggler:this.$dropdownToggler.value,$list:this._$optionsList.value}))}_focusElementAfterSelectOpened(){var e;const t=(e=this.$search.value)===null||e===void 0?void 0:e.querySelector('[role="search"]'),n=(this._$optionsList.value?[...this._$optionsList.value.querySelectorAll("h-option")]:[]).find(l=>!l.getAttribute("inactive")&&!l.getAttribute("disabled")&&!l.getAttribute("hidden")),o=this.selectedOptions[0]||n;
30t?t.focus():o?.focus()}async _focusElementAfterSelectOpenedAsync(){await this.updateComplete,requestAnimationFrame(()=>{var e;const t=(e=this.$search.value)===null||e===void 0?void 0:e.querySelector('[role="search"]'),n=(this._$optionsList.value?[...this._$optionsList.value.querySelectorAll("h-option")]:[]).find(l=>!l.hasAttribute("inactive")&&!l.hasAttribute("disabled")&&!l.hasAttribute("hidden")),o=this.selectedOptions[0]||n;t?t.focus():o?.focus()})}connectedCallback(){var e,t;super.connectedCallback(),this.classList.add(p.select),this.searchDisabled||this.classList.add(p.selectWithSearch),this.$searchLabel=document.querySelector(`[id="${this.assistiveTitleId}"]`),(e=this.$searchLabel)===null||e===void 0||e.setAttribute("aria-hidden","true"),this._selectController=this.multiple?new Be({host:this}):new Me({host:this}),this._selectContext.provide(j.selectedOptions$,this._selectController.selectedOptions$),this._selectContext.provide(j.isMultiselect,this.multiple),this._optionsObserver=new V(n=>this._updateOptionsView(n)),this._selectController.options$.subscribe(this._optionsObserver),this._selectedOptionsAriaObserver=new V(n=>this._updateLabelAria(n)),this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);const s=this.querySelector(`[slot="${re}"]`);s&&(!((t=s.textContent)===null||t===void 0)&&t.trim())&&(this.$placeholder=s),this._updateOptions(),this._addPlaceholderOptionIfNeeded(),this._setupEvents()}firstUpdated(e){super.firstUpdated(e),this._setupMutationObserver()}attributeChangedCallback(e,t,s){switch(super.attributeChangedCallback(e,t,s),e){case"error":this.error?this.classList.add(p.selectError):this.classList.remove(p.selectError);break;case"disabled":this.disabled?this.classList.add(p.selectDisabled):this.classList.remove(p.selectDisabled)}}_addPlaceholderOptionIfNeeded(){if(!this._canAddPlaceholder)return;const e=this._createPlaceholderOption();this._injectOptionIntoDOM(e),this._updateOptions()}get _canAddPlaceholder(){return this.multiple||this.required||this.noPlaceholderOption?!1:!!!this.querySelector("h-option[placeholder]")}_createPlaceholderOption(){var e;const t=document.createElement("h-option");t.setAttribute("value",""),(((e=this._selectController.selectedOptions$.getValue())===null||e===void 0?void 0:e.length)||0)>0||t.setAttribute("selected","true"),t.setAttribute("placeholder","true"),t.setAttribute("slot",N.content);const n=document.createElement(g.optionContent);return typeof this.$placeholder=="string"?n.textContent=this.$placeholder:this.$placeholder instanceof Node&&Array.from(this.$placeholder.childNodes).forEach(i=>{n.appendChild(i.cloneNode(!0))}),t.appendChild(n),t}_injectOptionIntoDOM(e){const t=this.querySelector(g.option);t&&t.parentNode?t.parentNode.insertBefore(e,t):this.appendChild(e)}_setupEvents(){this.addEventListener(he.deselectOption,this._handleOptionDeselect),this.addEventListener(ae.close,this._closeSelect)}_setupMutationObserver(){this._optionsMutationObserver=new MutationObserver(e=>{let t=!1,s=null;for(const n of e){const i=n.target;n.type==="attributes"&&n.attributeName==="selected"&&i.tagName&&i.tagName.toLowerCase()==="h-option"&&(t=!0,i.hasAttribute("selected")&&(s=i.getAttribute("value")))}if(t){const n=Array.from(this._$options.values()).map(o=>le.toModel(o));!this.multiple&&s!==null&&n.forEach(o=>{o.selected=o.value===s}),this._selectController.options$.notify(n);let i=n.filter(o=>o.selected);if(i.length===0){const o=n.find(l=>l.isPlaceholder);if(o){o.selected=!0;const l=this._$options.get(o.value);l&&l.setAttribute("selected","true"),i=[o]}}this._selectController.selectedOptions$.notify(i)}}),this._$optionsList.value&&this._optionsMutationObserver.observe(this._$optionsList.value,{attributes:!0,attributeFilter:["selected"],subtree:!0})}_appendNewHTMLOption(e,t){const s=this._$optionsList.value;if(!s)return;const{value:n,selected:i}=e,o=m.createHTMLOption(e);i&&this.updateOptionAriaAttribute(o),this._$options.set(n,o),m.appendHTMLOption(o,s,t)}updateOptionAriaAttribute(e){this.multiple||(this._$optionsList.value?[...this._$optionsList.value.querySelectorAll("h-option")]:[]).forEac
30h(s=>s.removeAttribute("aria-selected")),e.setAttribute(this.multiple?"aria-checked":"aria-selected",String(e.selected))}_removeHTMLOptions(e){this._$options=m.removeHTMLOptions(Array.from(this._$options.values()),e)}_selectOption(e){const t=this._selectController.getOption(e);if(!t)return;const s=this._$options.get(t.value),n=s?.querySelector("a");if(n){n.click();return}this.noDeselect?this._selectController.select(t):this._selectController.toggle(t),this.multiple||this._closeSelect(),this._dispatchChangeEvent()}_handleSearch({detail:e}){this._searchValue=e}update(e){super.update(e),e.has("_searchValue")&&this._selectController.filter(this._searchValue)}add(e,t){this._selectController.add(e,t)}removeOption(e){this._selectController.remove(e)}replace(e){this._selectController.replace(e)}getOption(e){return this._selectController.getOption(e)}select(e){this._selectController.select(e)}disconnectedCallback(){var e;super.disconnectedCallback(),this._selectController.options$.unsubscribe(this._optionsObserver),this._$options.clear(),(e=this._optionsMutationObserver)===null||e===void 0||e.disconnect()}_getClonedPlaceholderElement(){return this.$placeholder instanceof HTMLElement?this.$placeholder.cloneNode(!0):this.$placeholder}_searchNoResult(){return!!(!this._selectController.visibleOptionsCount&&Array.from(this._$options.keys()).length)}_renderOption(e){const t=document.createDocumentFragment();return t.appendChild(e),t}render(){var e,t,s,n,i,o;const l=(e=this._selectController.options$.getValue())!==null&&e!==void 0?e:[],b=!this.searchDisabled&&l.length>xe;return v` 31 <h-dropdown 32 ${M(this.$dropdown)} 33 @showed=${()=>this.opened=!0} 34 @hidden=${this._handleDropdownHidden} 35 name="${this.controlName}" 36 offset=${this.offset} 37 content-width="full" 38 prevent-focus-trap 39 no-autofocus 40 > 41 <h-dropdown-toggler 42 ${M(this.$dropdownToggler)} 43 name="${this.controlName}" 44 validation-container 45 aria-haspopup="listbox" 46 role="combobox" 47 aria-required="${this.required?"true":"false"}" 48 aria-activedescendant 49 role="combobox" 50 aria-controls="${this._selectOptionsId}" 51 aria-labelledby="${this.assistiveTitleId}" 52 > 53 ${this.getSlot(N.toggler)} 54 </h-dropdown-toggler> 55 56 <h-dropdown-content 57 class="${p.selectContent} ${this.error?p.selectContentError:""}" 58 ${M(this._$dropdownContent)} 59 name="${this.controlName}" 60 @focusin="${this._manageSelectFocusAria}" 61 > 62 <h-select-close-btn class="${p.selectCloseMobileButton}" @close=${this._closeSelect}></h-select-close-btn> 63 64 <div class=${p.selectLabel}>${(t=this.$searchLabel)===null||t===void 0?void 0:t.cloneNode(!0)}</div> 65 66 ${b?v` <h-select-search 67 class=${p.selectSearch} 68 ${M(this.$search)} 69 .value=${this._searchValue} 70 placeholder=${((s=this.translations)===null||s===void 0?void 0:s.search)||A.SEARCH} 71 @search=${this._handleSearch} 72 ></h-select-search>`:D} 73 74 <h-options 75 class="${p.selectOptions} ${this._searchNoResult()?p.selectOptionsEmpty:""}" 76 aria-labelledby="${this.assistiveTitleId}" 77 id="${this._selectOptionsId}" 78 ${M(this._$optionsList)} 79 @optionClicked=${this._handleOptionClicked} 80 @optionUpdated=${this._handleOptionUpdated} 81 > 82 ${Array.from(this._$options.entries()).length>0?ge(Array.from(this._$options.values()),f=>f.value,f=>this._renderOption(f)):D} 83 </h-options> 84 85 ${this._searchNoResult()?v` <div> 86 <p class=${p.selectNoResult}> 87 ${((n=this.translations)===null||n===void 0?void 0:n.noResultsFor)||A.NO_RESULTS_FOR}: 88 <em class=${p.selectSearchedPhrase}>"${this._searchValue}"</em> 89 </p> 90 </div>`:D} 91 ${this.multiple&&this._selectController.selectedOptionsCount>=1?v` 92 <section class=${p.selectFooter}> 93 <button class="${p.selectClearButton}" @click=${this._clearOptions}> 94 ${((i=this.translations)===null||i===void 0?void 0:i.reset)||A.RESET} 95 </button> 96 <h-select-close-btn class="${p.selectCloseButton}" @close=${this._closeSelect} 97 ><span slot=${Y} 98 >${((o=this.translations)===null||o===void 0?void 0:o.choose)||A.CHOOSE}</span 99 > 100 </h-select-close-btn> 101 </section> 102 `:D} 103 </h-dropdown-content> 104 </h-dropdown> 105 106 ${pe(this._selectController.selectedOptions$,f=>f.map(k=>v`<input type="hidden" name=${this.controlName} value=${k.value} />`))} 107 `}};h._components={search:K,icon:Ce,closeBtn:Q,toggler:P,dropdown:Le,dropdownContent:we,dropdownToggler:Ae};r([d({type:String,attribute:"control-name"}),a("design:type",String)],h.prototype,"controlName",void 0);r([d({type:String,attribute:"control-id"}),a("design:type",String)],h.prototype,"controlId",void 0);r([d({type:Boolean}),a("design:type",Boolean)],h.prototype,"multiple",void 0);r([d({type:Boolean,reflect:!0}),a("design:type",Boolean)],h.prototype,"opened",void 0);r([d({type:Number}),a("design:type",Number)],h.prototype,"offset",void 0);r([d({type:Boolean}),a("design:type",Boolean)],h.prototype,"error",void 0);r([d({type:Boolean}),a("design:type",Boolean)],h.prototype,"disabled",void 0);r([d({type:Boolean,attribute:"search-disabled"}),a("design:type",Boolean)],h.prototype,"searchDisabled",void 0);r([d({type:String}),a("design:type",String)],h.prototype,"type",void 0);r([d({type:Boolean}),a("design:type",Boolean)],h.prototype,"required",void 0);r([d({type:Array}),a("design:type",Array)],h.prototype,"optionsList",void 0);r([d({type:Boolean,attribute:"no-deselect"}),a("design:type",Boolean)],h.prototype,"noDeselect",void 0);r([d({type:String,attribute:"assistive-title-id"}),a("design:type",String)],h.prototype,"assistiveTitleId",void 0);r([d({type:Boolean,attribute:"no-placeholder-option"}),a("design:type",Boolean)],h.prototype,"noPlaceholderOption",void 0);r([d({type:Boolean,attribute:"dev_cached_select_options"}),a("design:type",Boolean)],h.prototype,"devCachedSelectOptions",void 0);r([d({converter:{fromAttribute(_){if(!_)return A;try{const e=JSON.parse(_);return typeof e!="object"||Array.isArray(e)||e===null?A:{...A,...e}}catch{return A}}}}),a("design:type",Object)],h.prototype,"translations",void 0);r([ee(),a("design:type",String)],h.prototype,"_searchValue",void 0);h=r([I("h-select"),a("design:paramtypes",[])],h);requestAnimationFrame(()=>{});
107globalThis.__phoenix_wc__=[$,J,Z,h];
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.