/*! * (C) Ionic http://ionicframework.com - MIT License */ import{d as t}from"./p-7b30edcc.js";import{MENU_BACK_BUTTON_PRIORITY as e}from"./p-0d6f7a8d.js";import{p as n}from"./p-06fee233.js";import{c as r}from"./p-1b3ffb2f.js";import{b as s}from"./p-2389b3f9.js";import{c as a}from"./p-942a9358.js";const o=t=>a().duration(t?400:300),i=t=>{let e,n;const r=t.width+8,i=a(),u=a();t.isEndSide?(e=r+"px",n="0px"):(e=-r+"px",n="0px"),i.addElement(t.menuInnerEl).fromTo("transform",`translateX(${e})`,`translateX(${n})`);const c="ios"===s(t),f=c?.2:.25;return u.addElement(t.backdropEl).fromTo("opacity",.01,f),o(c).addAnimation([i,u])},u=t=>{let e,n;const r=s(t),i=t.width;t.isEndSide?(e=-i+"px",n=i+"px"):(e=i+"px",n=-i+"px");const u=a().addElement(t.menuInnerEl).fromTo("transform",`translateX(${n})`,"translateX(0px)"),c=a().addElement(t.contentEl).fromTo("transform","translateX(0px)",`translateX(${e})`),f=a().addElement(t.backdropEl).fromTo("opacity",.01,.32);return o("ios"===r).addAnimation([u,c,f])},c=t=>{const e=s(t),n=t.width*(t.isEndSide?-1:1)+"px",r=a().addElement(t.contentEl).fromTo("transform","translateX(0px)",`translateX(${n})`);return o("ios"===e).addAnimation(r)},f=(()=>{const s=new Map,a=[],o=async(t,e=!1)=>{if(await w(),"start"===t||"end"===t){const r=a.filter((e=>e.side===t&&!e.disabled));if(r.length>=1)return r.length>1&&e&&n(`menuController queried for a menu on the "${t}" side, but ${r.length} menus were found. The first menu reference will be used. If this is not the behavior you want then pass the ID of the menu instead of its side.`,r.map((t=>t.el))),r[0].el;const s=a.filter((e=>e.side===t));if(s.length>=1)return s.length>1&&e&&n(`menuController queried for a menu on the "${t}" side, but ${s.length} menus were found. The first menu reference will be used. If this is not the behavior you want then pass the ID of the menu instead of its side.`,s.map((t=>t.el))),s[0].el}else if(null!=t)return d((e=>e.menuId===t));return d((t=>!t.disabled))||(a.length>0?a[0].el:void 0)},f=async()=>(await w(),m()),p=(t,e)=>{s.set(t,e)},m=()=>d((t=>t._isOpen)),l=()=>a.some((t=>t.isAnimating)),d=t=>{const e=a.find(t);if(void 0!==e)return e.el},w=()=>Promise.all(Array.from(document.querySelectorAll("ion-menu")).map((t=>new Promise((e=>r(t,e))))));return p("reveal",c),p("push",u),p("overlay",i),null==t||t.addEventListener("ionBackButton",(t=>{const n=m();n&&t.detail.register(e,(()=>n.close()))})),{registerAnimation:p,get:o,getMenus:async()=>(await w(),a.map((t=>t.el))),getOpen:f,isEnabled:async t=>{const e=await o(t);return!!e&&!e.disabled},swipeGesture:async(t,e)=>{const n=await o(e);return n&&(n.swipeGesture=t),n},isAnimating:async()=>(await w(),l()),isOpen:async t=>{if(null!=t){const e=await o(t);return void 0!==e&&e.isOpen()}return void 0!==await f()},enable:async(t,e)=>{const n=await o(e);return n&&(n.disabled=!t),n},toggle:async t=>{const e=await o(t,!0);return!!e&&e.toggle()},close:async t=>{const e=await(void 0!==t?o(t,!0):f());return void 0!==e&&e.close()},open:async t=>{const e=await o(t,!0);return!!e&&e.open()},_getOpenSync:m,_createAnimation:(t,e)=>{const n=s.get(t);if(!n)throw new Error("animation not registered");return n(e)},_register:t=>{a.indexOf(t)<0&&a.push(t)},_unregister:t=>{const e=a.indexOf(t);e>-1&&a.splice(e,1)},_setOpen:async(t,e,n)=>{if(l())return!1;if(e){const e=await f();e&&t.el!==e&&await e.setOpen(!1,!1)}return t._setOpen(e,n)}}})();export{f as m}