import{j as o}from"./p-2a37a33f.js";let n=0;const t=new WeakMap,e=o=>({create:n=>u(o,n),dismiss:(n,t,e)=>p(document,n,t,o,e),getTop:async()=>l(document,o)}),a=e("ion-alert"),s=e("ion-action-sheet"),i=e("ion-picker"),r=e("ion-popover"),c=o=>{const t=document;d(t);const e=n++;o.overlayIndex=e,o.hasAttribute("id")||(o.id=`ion-overlay-${e}`)},u=(o,n)=>customElements.whenDefined(o).then(()=>{const t=document,e=t.createElement(o);return e.classList.add("overlay-hidden"),Object.assign(e,n),y(t).appendChild(e),e.componentOnReady()}),d=o=>{0===n&&(n=1,o.addEventListener("focusin",n=>{const t=l(o);if(t&&t.backdropDismiss&&!b(t,n.target)){const o=t.querySelector("input,button");o&&o.focus()}}),o.addEventListener("ionBackButton",n=>{const t=l(o);t&&t.backdropDismiss&&n.detail.register(100,()=>t.dismiss(void 0,x))}),o.addEventListener("keyup",n=>{if("Escape"===n.key){const n=l(o);n&&n.backdropDismiss&&n.dismiss(void 0,x)}}))},p=(o,n,t,e,a)=>{const s=l(o,e,a);return s?s.dismiss(n,t):Promise.reject("overlay does not exist")},l=(o,n,t)=>{const e=((o,n)=>(void 0===n&&(n="ion-alert,ion-action-sheet,ion-loading,ion-modal,ion-picker,ion-popover,ion-toast"),Array.from(o.querySelectorAll(n)).filter(o=>o.overlayIndex>0)))(o,n);return void 0===t?e[e.length-1]:e.find(o=>o.id===t)},f=async(n,t,e,a,s)=>{if(n.presented)return;n.presented=!0,n.willPresent.emit();const i=n.enterAnimation?n.enterAnimation:o.get(t,"ios"===n.mode?e:a);await v(n,i,n.el,s)&&n.didPresent.emit()},m=async(n,e,a,s,i,r,c)=>{if(!n.presented)return!1;n.presented=!1;try{n.willDismiss.emit({data:e,role:a});const u=n.leaveAnimation?n.leaveAnimation:o.get(s,"ios"===n.mode?i:r);void 0!==u&&await v(n,u,n.el,c),n.didDismiss.emit({data:e,role:a}),t.delete(n)}catch(u){console.error(u)}return n.el.remove(),!0},y=o=>o.querySelector("ion-app")||o.body,v=async(n,e,a,s)=>{a.classList.remove("overlay-hidden");const i=e(a.shadowRoot||n.el,s);n.animated&&o.getBoolean("animated",!0)||i.duration(0),n.keyboardClose&&i.beforeAddWrite(()=>{const o=a.ownerDocument.activeElement;o&&o.matches("input, ion-input, ion-textarea")&&o.blur()});const r=t.get(n)||[];return t.set(n,[...r,i]),await i.play(),!0},h=(o,n)=>{let t;const e=new Promise(o=>t=o);return k(o,n,o=>{t(o.detail)}),e},k=(o,n,t)=>{const e=a=>{o.removeEventListener(n,e),t(a)};o.addEventListener(n,e)},w=o=>"cancel"===o||o===x,b=(o,n)=>{for(;n;){if(n===o)return!0;n=n.parentElement}return!1},g=o=>o(),j=(n,t)=>{if("function"==typeof n)return o.get("_zoneGate",g)(()=>{try{return n(t)}catch(o){console.error(o)}})},x="backdrop";export{x as B,f as a,i as b,t as c,m as d,h as e,r as f,s as g,a as h,w as i,c as p,j as s};