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,l){function o(e){try{s(r.next(e))}catch(e){l(e)}}function a(e){try{s(r["throw"](e))}catch(e){l(e)}}function s(e){e.done?i(e.value):n(e.value).then(o,a)}s((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},r,n,l,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return s([e,t])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(i=0)),i)try{if(r=1,n&&(l=a[0]&2?n["return"]:a[0]?n["throw"]||((l=n["return"])&&l.call(n),0):n.next)&&!(l=l.call(n,a[1])).done)return l;if(n=0,l)a=[a[0]&2,l.value];switch(a[0]){case 0:case 1:l=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(!(l=i.trys,l=l.length>0&&l[l.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!l||a[1]>l[0]&&a[1]-1){n=t.querySelector(".select-interface-option:nth-child(".concat(r+1,")"));if(n){p(n);l=n.querySelector("ion-radio, ion-checkbox");if(l){l.focus()}}}else{o=t.querySelector("ion-radio:not(.radio-disabled), ion-checkbox:not(.checkbox-disabled)");if(o){p(o.closest("ion-item"));o.focus()}}}return[2,t]}}))}))};e.prototype.createOverlay=function(e){var t=this.interface;if(t==="action-sheet"&&this.multiple){console.warn('Select interface cannot be "'.concat(t,'" with a multi-value select. Using the "alert" interface instead.'));t="alert"}if(t==="popover"&&!e){console.warn('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)}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.createPopoverOptions(t,i)}break;case"alert":var n=this.multiple?"checkbox":"radio";e.inputs=this.createAlertInputs(t,n,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 l="".concat(K," ").concat(n);return{role:c(t,r,i.compareWith)?"selected":"",text:e.textContent,cssClass:l,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 l=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var o="".concat(K," ").concat(l);return{type:t,cssClass:o,label:e.textContent||"",value:n,checked:c(i,n,r.compareWith),disabled:e.disabled}}));return n};e.prototype.createPopoverOptions=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 l="".concat(K," ").concat(n);return{text:e.textContent||"",cssClass:l,value:r,checked:c(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,l,o,a,s,c,d,h,p,u;return __generator(this,(function(f){t=this,i=t.fill,r=t.labelPlacement;n=this.interfaceOptions;l=Y(this);o=l==="md"?false:true;a=this.multiple;s=this.value;c=e;d="auto";if(this.legacyFormController.hasLegacyControl()){h=this.el.closest("ion-item");if(h&&(h.classList.contains("item-label-floating")||h.classList.contains("item-label-stacked"))){c=Object.assign(Object.assign({},e),{detail:{ionShadowTarget:h}});d="cover"}}else{p=r==="floating"||r==="stacked";if(p||l==="md"&&i!==undefined){d="cover"}else{c=Object.assign(Object.assign({},e),{detail:{ionShadowTarget:this.nativeWrapperEl}})}}u=Object.assign(Object.assign({mode:l,event:c,alignment:"center",size:d,showBackdrop:o},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.createPopoverOptions(this.childOpts,s)}});return[2,m.create(u)]}))}))};e.prototype.openActionSheet=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i;return __generator(this,(function(r){e=Y(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,v.create(i)]}))}))};e.prototype.openAlert=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i,r,n,l;var o=this;return __generator(this,(function(a){if(this.legacyFormController.hasLegacyControl()){e=this.getLabel();t=e?e.textContent:null}else{t=this.labelText}i=this.interfaceOptions;r=this.multiple?"checkbox":"radio";n=Y(this);l=Object.assign(Object.assign({mode:n},i),{header:i.header?i.header:t,inputs:this.createAlertInputs(this.childOpts,r,this.value),buttons:[{text:this.cancelText,role:"cancel",handler:function(){o.ionCancel.emit()}},{text:this.okText,handler:function(e){o.setValue(e)}}],cssClass:["select-alert",i.cssClass,this.multiple?"multiple-select-alert":"single-select-alert"]});return[2,x.create(l)]}))}))};e.prototype.close=function(){if(!this.overlay){return Promise.resolve(false)}return this.overlay.dismiss()};e.prototype.getLabel=function(){return u(this.el)};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};if(this.legacyFormController.hasLegacyControl()){t["interactive"]=true;t["select"]=true;t["select-disabled"]=e;t["has-placeholder"]=this.placeholder!==undefined;t["has-value"]=this.hasValue();t["has-focus"]=this.isExpanded;t["legacy"]=!!this.legacy}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=Y(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.renderSelect=function(){var e;var t=this;var i=this,l=i.disabled,o=i.el,a=i.isExpanded,s=i.expandedIcon,c=i.labelPlacement,d=i.justify,h=i.placeholder,p=i.fill,u=i.shape,b=i.name,g=i.value;var m=Y(this);var v=c==="floating"||c==="stacked";var x=!v;var w=y(o)?"rtl":"ltr";var z=k("ion-item",this.el);var _=m==="md"&&p!=="outline"&&!z;var O=this.hasValue();var C=o.querySelector('[slot="start"], [slot="end"]')!==null;f(true,o,b,P(g),l);var S=c==="stacked"||c==="floating"&&(O||a||C);return r(n,{onClick:this.onClick,class:j(this.color,(e={},e[m]=true,e["in-item"]=z,e["in-item-color"]=k("ion-item.ion-color",o),e["select-disabled"]=l,e["select-expanded"]=a,e["has-expanded-icon"]=s!==undefined,e["has-value"]=O,e["label-floating"]=S,e["has-placeholder"]=h!==undefined,e["ion-focusable"]=true,e["select-".concat(w)]=true,e["select-fill-".concat(p)]=p!==undefined,e["select-justify-".concat(d)]=x,e["select-shape-".concat(u)]=u!==undefined,e["select-label-placement-".concat(c)]=true,e))},r("label",{class:"select-wrapper",id:"select-label"},this.renderLabelContainer(),r("div",{class:"select-wrapper-inner"},r("slot",{name:"start"}),r("div",{class:"native-wrapper",ref:function(e){return t.nativeWrapperEl=e},part:"container"},this.renderSelectText(),this.renderListbox()),r("slot",{name:"end"}),!v&&this.renderSelectIcon()),v&&this.renderSelectIcon(),_&&r("div",{class:"select-highlight"})))};e.prototype.renderLegacySelect=function(){var e;if(!this.hasLoggedDeprecationWarning){g('ion-select now requires providing a label with either the "label" property or the "aria-label" attribute. To migrate, remove any usage of "ion-label" and pass the label text to either the "label" property or the "aria-label" attribute.\n\nExample: ...\nExample with aria-label: ...\n\nDevelopers can use the "legacy" property to continue using the legacy form markup. This property will be removed in an upcoming major release of Ionic where this form control will use the modern form markup.',this.el);if(this.legacy){g('ion-select is being used with the "legacy" property enabled which will forcibly enable the legacy form markup. This property will be removed in an upcoming major release of Ionic where this form control will use the modern form markup.\n Developers can dismiss this warning by removing their usage of the "legacy" property and using the new select syntax.',this.el)}this.hasLoggedDeprecationWarning=true}var t=this,i=t.disabled,l=t.el,o=t.inputId,a=t.isExpanded,s=t.expandedIcon,c=t.name,d=t.placeholder,h=t.value;var p=Y(this);var u=b(l,o),m=u.labelText,v=u.labelId;f(true,l,c,P(h),i);var x=this.getText();var w=x;if(w===""&&d!==undefined){w=d}var y=m!==undefined?w!==""?"".concat(w,", ").concat(m):m:w;return r(n,{onClick:this.onClick,role:"button","aria-haspopup":"listbox","aria-disabled":i?"true":null,"aria-label":y,class:(e={},e[p]=true,e["in-item"]=k("ion-item",l),e["in-item-color"]=k("ion-item.ion-color",l),e["select-disabled"]=i,e["select-expanded"]=a,e["has-expanded-icon"]=s!==undefined,e["legacy-select"]=true,e)},this.renderSelectText(),this.renderSelectIcon(),r("label",{id:v},y),this.renderListbox())};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 l={"select-text":true,"select-placeholder":i};var o=i?"placeholder":"text";return r("div",{"aria-hidden":"true",class:l,part:o},n)};e.prototype.renderSelectIcon=function(){var e=Y(this);var t=this,i=t.isExpanded,n=t.toggleIcon,l=t.expandedIcon;var o;if(i&&l!==undefined){o=l}else{var a=e==="ios"?O:C;o=n!==null&&n!==void 0?n:a}return r("ion-icon",{class:"select-icon",part:"icon","aria-hidden":"true",icon:o})};Object.defineProperty(e.prototype,"ariaLabel",{get:function(){var e,t;var i=this,r=i.placeholder,n=i.el,l=i.inputId,o=i.inheritedAttributes;var a=this.getText();var s=b(n,l).labelText;var c=(t=(e=this.labelText)!==null&&e!==void 0?e:o["aria-label"])!==null&&t!==void 0?t:s;var d=a;if(d===""&&r!==undefined){d=r}if(c!==undefined){d=d===""?c:"".concat(c,", ").concat(d)}return d},enumerable:false,configurable:true});e.prototype.renderListbox=function(){var e=this;var t=this,i=t.disabled,n=t.inputId,l=t.isExpanded;return r("button",{disabled:i,id:n,"aria-label":this.ariaLabel,"aria-haspopup":"dialog","aria-expanded":"".concat(l),onFocus:this.onFocus,onBlur:this.onBlur,ref:function(t){return e.focusEl=t}})};e.prototype.render=function(){var e=this.legacyFormController;return e.hasLegacyControl()?this.renderLegacySelect():this.renderSelect()};Object.defineProperty(e.prototype,"el",{get:function(){return l(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 P=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 D(e,t,i)})).filter((function(e){return e!==null})).join(", ")}else{return D(e,t,i)||""}};var D=function(e,t,i){var r=e.find((function(e){return d(t,I(e),i)}));return r?r.textContent:null};var U=0;var K="select-interface-option";F.style={ios:T,md:E};var L=":host{display:none}";var q=L;var G=e("ion_select_option",function(){function e(e){t(this,e);this.inputId="ion-selopt-".concat(H++);this.disabled=false;this.value=undefined}e.prototype.render=function(){return r(n,{key:"69bd6a2dbbc0ab32cc607a74df10f3fb3d6e3295",role:"option",id:this.inputId,class:Y(this)})};Object.defineProperty(e.prototype,"el",{get:function(){return l(this)},enumerable:false,configurable:true});return e}());var H=0;G.style=q;var J=".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 M=J;var N=".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){opacity: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, 56, 128, 255), 0.08);--background-focused:var(--ion-color-primary, #3880ff);--background-focused-opacity:0.2;--background-hover:var(--ion-color-primary, #3880ff);--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, #3880ff)}";var Q=N;var R=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){w(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},z(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);o(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},z(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,l=e.options,o=e.subHeader;var a=o!==undefined||i!==undefined;return r(n,{key:"46e495ce7001131eb8b54073018de89401a99b81",class:Y(this)},r("ion-list",{key:"afdb72359c3751c6b372af1a778398463d1da397"},t!==undefined&&r("ion-list-header",null,t),a&&r("ion-item",null,r("ion-label",{class:"ion-text-wrap"},o!==undefined&&r("h3",null,o),i!==undefined&&r("p",null,i))),this.renderOptions(l)))};Object.defineProperty(e.prototype,"el",{get:function(){return l(this)},enumerable:false,configurable:true});return e}());R.style={ios:M,md:Q}}}}));