UNPKG

@ionic/core

Version:
4 lines 1.14 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{w as t}from"./p-ZjP4CjeZ.js";import{l as e,o as n}from"./p-B_U9CtaY.js";const o=()=>e.get("experimentalCloseWatcher",!1)&&void 0!==t&&"CloseWatcher"in t,i=()=>{document.addEventListener("backbutton",(()=>{}))},r=()=>{const e=document;let i=!1;const r=()=>{if(i)return;let t=0,o=[];const r=new CustomEvent("ionBackButton",{bubbles:!1,detail:{register(e,n){o.push({priority:e,handler:n,id:t++})}}});e.dispatchEvent(r);const a=()=>{if(o.length>0){let t={priority:Number.MIN_SAFE_INTEGER,handler:()=>{},id:-1};o.forEach((e=>{e.priority>=t.priority&&(t=e)})),i=!0,o=o.filter((e=>e.id!==t.id)),(async t=>{try{if(null==t?void 0:t.handler){const e=t.handler(a);null!=e&&await e}}catch(t){n("[ion-app] - Exception in startHardwareBackButton:",t)}})(t).then((()=>i=!1))}};a()};if(o()){let e;const n=()=>{null==e||e.destroy(),e=new t.CloseWatcher,e.onclose=()=>{r(),n()}};n()}else e.addEventListener("backbutton",r)},a=100,s=99;export{s as MENU_BACK_BUTTON_PRIORITY,a as OVERLAY_BACK_BUTTON_PRIORITY,i as blockHardwareBackButton,o as shouldUseCloseWatcher,r as startHardwareBackButton}