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