var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function l(e){try{s(r.next(e))}catch(e){o(e)}}function a(e){try{s(r["throw"](e))}catch(e){o(e)}}function s(e){e.done?i(e.value):n(e.value).then(l,a)}s((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,n,o,l;return l={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(l[Symbol.iterator]=function(){return this}),l;function a(e){return function(t){return s([e,t])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(l&&(l=0,a[0]&&(i=0)),i)try{if(r=1,n&&(o=a[0]&2?n["return"]:a[0]?n["throw"]||((o=n["return"])&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;if(n=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;n=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]-1){var i=t.querySelector(".select-interface-option:nth-child(".concat(e+1,")"));if(i){var r=i.querySelector("ion-radio, ion-checkbox");if(r){i.scrollIntoView({block:"nearest"});r.setFocus()}p(i)}}else{var n=t.querySelector("ion-radio:not(.radio-disabled), ion-checkbox:not(.checkbox-disabled)");if(n){n.setFocus();p(n.closest("ion-item"))}}};if(this.interface==="modal"){t.addEventListener("ionModalWillPresent",r,{once:true})}else if(this.interface==="popover"){t.addEventListener("ionPopoverWillPresent",r,{once:true})}else{n=function(){requestAnimationFrame((function(){r()}))};if(this.interface==="alert"){t.addEventListener("ionAlertWillPresent",n,{once:true})}else if(this.interface==="action-sheet"){t.addEventListener("ionActionSheetWillPresent",n,{once:true})}}t.onDidDismiss().then((function(){o.overlay=undefined;o.isExpanded=false;o.ionDismiss.emit();o.setFocus()}));return[4,t.present()];case 2:l.sent();return[2,t]}}))}))};e.prototype.createOverlay=function(e){var t=this.interface;if(t==="action-sheet"&&this.multiple){f('[ion-select] - Interface cannot be "'.concat(t,'" with a multi-value select. Using the "alert" interface instead.'));t="alert"}if(t==="popover"&&!e){f('[ion-select] - Interface cannot be a "'.concat(t,'" without passing an event. Using the "alert" interface instead.'));t="alert"}if(t==="action-sheet"){return this.openActionSheet()}if(t==="popover"){return this.openPopover(e)}if(t==="modal"){return this.openModal()}return this.openAlert()};e.prototype.updateOverlayOptions=function(){var e=this.overlay;if(!e){return}var t=this.childOpts;var i=this.value;switch(this.interface){case"action-sheet":e.buttons=this.createActionSheetButtons(t,i);break;case"popover":var r=e.querySelector("ion-select-popover");if(r){r.options=this.createOverlaySelectOptions(t,i)}break;case"modal":var n=e.querySelector("ion-select-modal");if(n){n.options=this.createOverlaySelectOptions(t,i)}break;case"alert":var o=this.multiple?"checkbox":"radio";e.inputs=this.createAlertInputs(t,o,i);break}};e.prototype.createActionSheetButtons=function(e,t){var i=this;var r=e.map((function(e){var r=I(e);var n=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var o="".concat(U," ").concat(n);return{role:s(t,r,i.compareWith)?"selected":"",text:e.textContent,cssClass:o,handler:function(){i.setValue(r)}}}));r.push({text:this.cancelText,role:"cancel",handler:function(){i.ionCancel.emit()}});return r};e.prototype.createAlertInputs=function(e,t,i){var r=this;var n=e.map((function(e){var n=I(e);var o=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var l="".concat(U," ").concat(o);return{type:t,cssClass:l,label:e.textContent||"",value:n,checked:s(i,n,r.compareWith),disabled:e.disabled}}));return n};e.prototype.createOverlaySelectOptions=function(e,t){var i=this;var r=e.map((function(e){var r=I(e);var n=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var o="".concat(U," ").concat(n);return{text:e.textContent||"",cssClass:o,value:r,checked:s(t,r,i.compareWith),disabled:e.disabled,handler:function(e){i.setValue(e);if(!i.multiple){i.close()}}}}));return r};e.prototype.openPopover=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,r,n,o,l,a,s,c,d,h,p;return __generator(this,(function(f){t=this,i=t.fill,r=t.labelPlacement;n=this.interfaceOptions;o=O(this);l=o==="md"?false:true;a=this.multiple;s=this.value;c=e;d="auto";h=r==="floating"||r==="stacked";if(h||o==="md"&&i!==undefined){d="cover"}else{c=Object.assign(Object.assign({},e),{detail:{ionShadowTarget:this.nativeWrapperEl}})}p=Object.assign(Object.assign({mode:o,event:c,alignment:"center",size:d,showBackdrop:l},n),{component:"ion-select-popover",cssClass:["select-popover",n.cssClass],componentProps:{header:n.header,subHeader:n.subHeader,message:n.message,multiple:a,value:s,options:this.createOverlaySelectOptions(this.childOpts,s)}});return[2,u.create(p)]}))}))};e.prototype.openActionSheet=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i;return __generator(this,(function(r){e=O(this);t=this.interfaceOptions;i=Object.assign(Object.assign({mode:e},t),{buttons:this.createActionSheetButtons(this.childOpts,this.value),cssClass:["select-action-sheet",t.cssClass]});return[2,b.create(i)]}))}))};e.prototype.openAlert=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i,r;var n=this;return __generator(this,(function(o){e=this.interfaceOptions;t=this.multiple?"checkbox":"radio";i=O(this);r=Object.assign(Object.assign({mode:i},e),{header:e.header?e.header:this.labelText,inputs:this.createAlertInputs(this.childOpts,t,this.value),buttons:[{text:this.cancelText,role:"cancel",handler:function(){n.ionCancel.emit()}},{text:this.okText,handler:function(e){n.setValue(e)}}],cssClass:["select-alert",e.cssClass,this.multiple?"multiple-select-alert":"single-select-alert"]});return[2,m.create(r)]}))}))};e.prototype.openModal=function(){var e=this,t=e.multiple,i=e.value,r=e.interfaceOptions;var n=O(this);var o=Object.assign(Object.assign({},r),{mode:n,cssClass:["select-modal",r.cssClass],component:"ion-select-modal",componentProps:{header:r.header,multiple:t,value:i,options:this.createOverlaySelectOptions(this.childOpts,i)}});return g.create(o)};e.prototype.close=function(){if(!this.overlay){return Promise.resolve(false)}return this.overlay.dismiss()};e.prototype.hasValue=function(){return this.getText()!==""};Object.defineProperty(e.prototype,"childOpts",{get:function(){return Array.from(this.el.querySelectorAll("ion-select-option"))},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"labelText",{get:function(){var e=this.label;if(e!==undefined){return e}var t=this.labelSlot;if(t!==null){return t.textContent}return},enumerable:false,configurable:true});e.prototype.getText=function(){var e=this.selectedText;if(e!=null&&e!==""){return e}return B(this.childOpts,this.value,this.compareWith)};e.prototype.setFocus=function(){if(this.focusEl){this.focusEl.focus()}};e.prototype.emitStyle=function(){var e=this.disabled;var t={"interactive-disabled":e};this.ionStyle.emit(t)};e.prototype.renderLabel=function(){var e=this.label;return r("div",{class:{"label-text-wrapper":true,"label-text-wrapper-hidden":!this.hasLabel},part:"label"},e===undefined?r("slot",{name:"label"}):r("div",{class:"label-text"},e))};e.prototype.componentDidRender=function(){var e;(e=this.notchController)===null||e===void 0?void 0:e.calculateNotchWidth()};Object.defineProperty(e.prototype,"labelSlot",{get:function(){return this.el.querySelector('[slot="label"]')},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"hasLabel",{get:function(){return this.label!==undefined||this.labelSlot!==null},enumerable:false,configurable:true});e.prototype.renderLabelContainer=function(){var e=this;var t=O(this);var i=t==="md"&&this.fill==="outline";if(i){return[r("div",{class:"select-outline-container"},r("div",{class:"select-outline-start"}),r("div",{class:{"select-outline-notch":true,"select-outline-notch-hidden":!this.hasLabel}},r("div",{class:"notch-spacer","aria-hidden":"true",ref:function(t){return e.notchSpacerEl=t}},this.label)),r("div",{class:"select-outline-end"})),this.renderLabel()]}return this.renderLabel()};e.prototype.renderSelectText=function(){var e=this.placeholder;var t=this.getText();var i=false;var n=t;if(n===""&&e!==undefined){n=e;i=true}var o={"select-text":true,"select-placeholder":i};var l=i?"placeholder":"text";return r("div",{"aria-hidden":"true",class:o,part:l},n)};e.prototype.renderSelectIcon=function(){var e=O(this);var t=this,i=t.isExpanded,n=t.toggleIcon,o=t.expandedIcon;var l;if(i&&o!==undefined){l=o}else{var a=e==="ios"?z:_;l=n!==null&&n!==void 0?n:a}return r("ion-icon",{class:"select-icon",part:"icon","aria-hidden":"true",icon:l})};Object.defineProperty(e.prototype,"ariaLabel",{get:function(){var e;var t=this,i=t.placeholder,r=t.inheritedAttributes;var n=this.getText();var o=(e=r["aria-label"])!==null&&e!==void 0?e:this.labelText;var l=n;if(l===""&&i!==undefined){l=i}if(o!==undefined){l=l===""?o:"".concat(o,", ").concat(l)}return l},enumerable:false,configurable:true});e.prototype.renderListbox=function(){var e=this;var t=this,i=t.disabled,n=t.inputId,o=t.isExpanded,l=t.required;return r("button",{disabled:i,id:n,"aria-label":this.ariaLabel,"aria-haspopup":"dialog","aria-expanded":"".concat(o),"aria-describedby":this.getHintTextID(),"aria-invalid":this.getHintTextID()===this.errorTextId,"aria-required":"".concat(l),onFocus:this.onFocus,onBlur:this.onBlur,ref:function(t){return e.focusEl=t}})};e.prototype.getHintTextID=function(){var e=this,t=e.el,i=e.helperText,r=e.errorText,n=e.helperTextId,o=e.errorTextId;if(t.classList.contains("ion-touched")&&t.classList.contains("ion-invalid")&&r){return o}if(i){return n}return undefined};e.prototype.renderHintText=function(){var e=this,t=e.helperText,i=e.errorText,n=e.helperTextId,o=e.errorTextId;return[r("div",{id:n,class:"helper-text",part:"supporting-text helper-text"},t),r("div",{id:o,class:"error-text",part:"supporting-text error-text"},i)]};e.prototype.renderBottomContent=function(){var e=this,t=e.helperText,i=e.errorText;var n=!!t||!!i;if(!n){return}return r("div",{class:"select-bottom"},this.renderHintText())};e.prototype.render=function(){var e;var t=this;var i=this,o=i.disabled,l=i.el,a=i.isExpanded,s=i.expandedIcon,c=i.labelPlacement,d=i.justify,p=i.placeholder,f=i.fill,u=i.shape,b=i.name,m=i.value,g=i.hasFocus;var v=O(this);var y=c==="floating"||c==="stacked";var j=!y&&d!==undefined;var z=x(l)?"rtl":"ltr";var _=w("ion-item",this.el);var C=v==="md"&&f!=="outline"&&!_;var P=this.hasValue();var Y=l.querySelector('[slot="start"], [slot="end"]')!==null;h(true,l,b,W(m),o);var A=c==="stacked"||c==="floating"&&(P||a||Y);return r(n,{key:"6dd3c92dc3c587960d767c7dd1c142fc20bef8ed",onClick:this.onClick,class:k(this.color,(e={},e[v]=true,e["in-item"]=_,e["in-item-color"]=w("ion-item.ion-color",l),e["select-disabled"]=o,e["select-expanded"]=a,e["has-expanded-icon"]=s!==undefined,e["has-value"]=P,e["label-floating"]=A,e["has-placeholder"]=p!==undefined,e["has-focus"]=g,e["ion-focusable"]=true,e["select-".concat(z)]=true,e["select-fill-".concat(f)]=f!==undefined,e["select-justify-".concat(d)]=j,e["select-shape-".concat(u)]=u!==undefined,e["select-label-placement-".concat(c)]=true,e))},r("label",{key:"bc80ee471debb20b33d1cf55f55932b621f1744a",class:"select-wrapper",id:"select-label",onClick:this.onLabelClick},this.renderLabelContainer(),r("div",{key:"deea85c3a3769e90af0933c522028148ee5781a3",class:"select-wrapper-inner"},r("slot",{key:"af8192f4d8d5426b39a00ef2ed96f3c4a9e12908",name:"start"}),r("div",{key:"6c278fc6c56b18e26cae930d375aa1da05af135b",class:"native-wrapper",ref:function(e){return t.nativeWrapperEl=e},part:"container"},this.renderSelectText(),this.renderListbox()),r("slot",{key:"c459d54471029872b8b3e63f7dfb6bdb869b4942",name:"end"}),!y&&this.renderSelectIcon()),y&&this.renderSelectIcon(),C&&r("div",{key:"718960718fa91163dd4412e1865f476fef089127",class:"select-highlight"})),this.renderBottomContent())};Object.defineProperty(e.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{disabled:["styleChanged"],isExpanded:["styleChanged"],placeholder:["styleChanged"],value:["styleChanged"]}},enumerable:false,configurable:true});return e}());var I=function(e){var t=e.value;return t===undefined?e.textContent||"":t};var W=function(e){if(e==null){return undefined}if(Array.isArray(e)){return e.join(",")}return e.toString()};var B=function(e,t,i){if(t===undefined){return""}if(Array.isArray(t)){return t.map((function(t){return F(e,t,i)})).filter((function(e){return e!==null})).join(", ")}else{return F(e,t,i)||""}};var F=function(e,t,i){var r=e.find((function(e){return c(t,I(e),i)}));return r?r.textContent:null};var T=0;var U="select-interface-option";S.style={ios:P,md:A};var q=":host{display:none}";var E=q;var K=e("ion_select_option",function(){function e(e){t(this,e);this.inputId="ion-selopt-".concat(L++);this.disabled=false;this.value=undefined}e.prototype.render=function(){return r(n,{key:"8c96c199ce3a3065de3fe446500f567236e0610a",role:"option",id:this.inputId,class:O(this)})};Object.defineProperty(e.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});return e}());var L=0;K.style=E;var D=".sc-ion-select-popover-ios-h ion-list.sc-ion-select-popover-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-list-header.sc-ion-select-popover-ios,ion-label.sc-ion-select-popover-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}.sc-ion-select-popover-ios-h{overflow-y:auto}";var G=D;var H=".sc-ion-select-popover-md-h ion-list.sc-ion-select-popover-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-list-header.sc-ion-select-popover-md,ion-label.sc-ion-select-popover-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}.sc-ion-select-popover-md-h{overflow-y:auto}ion-list.sc-ion-select-popover-md ion-radio.sc-ion-select-popover-md::part(container){display:none}ion-list.sc-ion-select-popover-md ion-radio.sc-ion-select-popover-md::part(label){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0}ion-item.sc-ion-select-popover-md{--inner-border-width:0}.item-radio-checked.sc-ion-select-popover-md{--background:rgba(var(--ion-color-primary-rgb, 0, 84, 233), 0.08);--background-focused:var(--ion-color-primary, #0054e9);--background-focused-opacity:0.2;--background-hover:var(--ion-color-primary, #0054e9);--background-hover-opacity:0.12}.item-checkbox-checked.sc-ion-select-popover-md{--background-activated:var(--ion-item-color, var(--ion-text-color, #000));--background-focused:var(--ion-item-color, var(--ion-text-color, #000));--background-hover:var(--ion-item-color, var(--ion-text-color, #000));--color:var(--ion-color-primary, #0054e9)}";var M=H;var J=e("ion_select_popover",function(){function e(e){t(this,e);this.header=undefined;this.subHeader=undefined;this.message=undefined;this.multiple=undefined;this.options=[]}e.prototype.findOptionFromEvent=function(e){var t=this.options;return t.find((function(t){return t.value===e.target.value}))};e.prototype.callOptionHandler=function(e){var t=this.findOptionFromEvent(e);var i=this.getValues(e);if(t===null||t===void 0?void 0:t.handler){v(t.handler,i)}};e.prototype.dismissParentPopover=function(){var e=this.el.closest("ion-popover");if(e){e.dismiss()}};e.prototype.setChecked=function(e){var t=this.multiple;var i=this.findOptionFromEvent(e);if(t&&i){i.checked=e.detail.checked}};e.prototype.getValues=function(e){var t=this,i=t.multiple,r=t.options;if(i){return r.filter((function(e){return e.checked})).map((function(e){return e.value}))}var n=this.findOptionFromEvent(e);return n?n.value:undefined};e.prototype.renderOptions=function(e){var t=this.multiple;switch(t){case true:return this.renderCheckboxOptions(e);default:return this.renderRadioOptions(e)}};e.prototype.renderCheckboxOptions=function(e){var t=this;return e.map((function(e){return r("ion-item",{class:Object.assign({"item-checkbox-checked":e.checked},y(e.cssClass))},r("ion-checkbox",{value:e.value,disabled:e.disabled,checked:e.checked,justify:"start",labelPlacement:"end",onIonChange:function(e){t.setChecked(e);t.callOptionHandler(e);l(t)}},e.text))}))};e.prototype.renderRadioOptions=function(e){var t=this;var i=e.filter((function(e){return e.checked})).map((function(e){return e.value}))[0];return r("ion-radio-group",{value:i,onIonChange:function(e){return t.callOptionHandler(e)}},e.map((function(e){return r("ion-item",{class:Object.assign({"item-radio-checked":e.value===i},y(e.cssClass))},r("ion-radio",{value:e.value,disabled:e.disabled,onClick:function(){return t.dismissParentPopover()},onKeyUp:function(e){if(e.key===" "){t.dismissParentPopover()}}},e.text))})))};e.prototype.render=function(){var e=this,t=e.header,i=e.message,o=e.options,l=e.subHeader;var a=l!==undefined||i!==undefined;return r(n,{key:"542367ab8fb72bfebf7e65630b91017d68827fd6",class:O(this)},r("ion-list",{key:"f2f0f37e1365cd7780b02de1a1698700d0df48a7"},t!==undefined&&r("ion-list-header",{key:"4b8800a68e800f19277a44b7074ca24b70218daf"},t),a&&r("ion-item",{key:"932b7903daf97d5a57d289b7ee49e868bb9b0cf5"},r("ion-label",{key:"fc3f1b69aa2a0bc6125d35692dcad3a8a99fd160",class:"ion-text-wrap"},l!==undefined&&r("h3",{key:"eceab2f47afa95f04b138342b0bdbfa1f50919a8"},l),i!==undefined&&r("p",{key:"70f4e27ad1316318efd0c17efce31e5e45c8fa02"},i))),this.renderOptions(o)))};Object.defineProperty(e.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});return e}());J.style={ios:G,md:M}}}}));