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){n=t.querySelector(".select-interface-option:nth-child(".concat(r+1,")"));if(n){h(n);o=n.querySelector("ion-radio, ion-checkbox");if(o){o.focus()}}}else{l=t.querySelector("ion-radio:not(.radio-disabled), ion-checkbox:not(.checkbox-disabled)");if(l){h(l.closest("ion-item"));l.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=A(e);var n=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var o="".concat(E," ").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=A(e);var o=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var l="".concat(E," ").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.createPopoverOptions=function(e,t){var i=this;var r=e.map((function(e){var r=A(e);var n=Array.from(e.classList).filter((function(e){return e!=="hydrated"})).join(" ");var o="".concat(E," ").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(u){t=this,i=t.fill,r=t.labelPlacement;n=this.interfaceOptions;o=z(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.createPopoverOptions(this.childOpts,s)}});return[2,f.create(p)]}))}))};e.prototype.openActionSheet=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i;return __generator(this,(function(r){e=z(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,u.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=z(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,b.create(r)]}))}))};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=z(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=z(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"?y:j;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;return r("button",{disabled:i,id:n,"aria-label":this.ariaLabel,"aria-haspopup":"dialog","aria-expanded":"".concat(o),onFocus:this.onFocus,onBlur:this.onBlur,ref:function(t){return e.focusEl=t}})};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,h=i.placeholder,f=i.fill,u=i.shape,b=i.name,m=i.value;var w=z(this);var k=c==="floating"||c==="stacked";var y=!k;var j=g(l)?"rtl":"ltr";var _=v("ion-item",this.el);var O=w==="md"&&f!=="outline"&&!_;var C=this.hasValue();var Y=l.querySelector('[slot="start"], [slot="end"]')!==null;p(true,l,b,P(m),o);var S=c==="stacked"||c==="floating"&&(C||a||Y);return r(n,{key:"34a8ad246debbd7f1220ba1816d6cf427a24df8f",onClick:this.onClick,class:x(this.color,(e={},e[w]=true,e["in-item"]=_,e["in-item-color"]=v("ion-item.ion-color",l),e["select-disabled"]=o,e["select-expanded"]=a,e["has-expanded-icon"]=s!==undefined,e["has-value"]=C,e["label-floating"]=S,e["has-placeholder"]=h!==undefined,e["ion-focusable"]=true,e["select-".concat(j)]=true,e["select-fill-".concat(f)]=f!==undefined,e["select-justify-".concat(d)]=y,e["select-shape-".concat(u)]=u!==undefined,e["select-label-placement-".concat(c)]=true,e))},r("label",{key:"b4deb5c56fd7d97d8d09850e9b2758cecc59160a",class:"select-wrapper",id:"select-label"},this.renderLabelContainer(),r("div",{key:"5608f30189b941e8d737480308633376d7c554ec",class:"select-wrapper-inner"},r("slot",{key:"5448dcd362880effebec59b84ca81b140bf078b7",name:"start"}),r("div",{key:"ee140365597d0857621b4c4cd0577e0c51355f85",class:"native-wrapper",ref:function(e){return t.nativeWrapperEl=e},part:"container"},this.renderSelectText(),this.renderListbox()),r("slot",{key:"0aff40616a2ffaae06dfbb1282072d48435b220f",name:"end"}),!k&&this.renderSelectIcon()),k&&this.renderSelectIcon(),O&&r("div",{class:"select-highlight"})))};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 A=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 T(e,t,i)})).filter((function(e){return e!==null})).join(", ")}else{return T(e,t,i)||""}};var T=function(e,t,i){var r=e.find((function(e){return c(t,A(e),i)}));return r?r.textContent:null};var U=0;var E="select-interface-option";S.style={ios:O,md:Y};var F=":host{display:none}";var I=F;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:"7830b6152ba185b327d02fe96fd415cdcd16f48d",role:"option",id:this.inputId,class:z(this)})};Object.defineProperty(e.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});return e}());var L=0;K.style=I;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){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, 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 q=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){m(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},w(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},w(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:"81e4df60ad6dab49bdde30f4c3e460ba425f0c89",class:z(this)},r("ion-list",{key:"940f13aab8c6cebbeb7d4b6d4d64b3c67d4c953d"},t!==undefined&&r("ion-list-header",null,t),a&&r("ion-item",null,r("ion-label",{class:"ion-text-wrap"},l!==undefined&&r("h3",null,l),i!==undefined&&r("p",null,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:q}}}}));