@ionic/core
Version:
Base components for Ionic
4 lines • 34.2 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{r as t,d as o,e as a,m as i,w as e,l as r,h as s,j as n,k as d}from"./p-B_U9CtaY.js";import{f as p,i as l,d as h,r as c,a as m,p as f}from"./p-QwEXyOze.js";import{C as b,a as u,d as x}from"./p-BhLqfMrf.js";import{e as w,g as v,r as g,b as k,h as y}from"./p-Do-uqmtX.js";import{c as Y}from"./p-B-hirT0v.js";import{g as A}from"./p-CIGNaXM1.js";import{G as D,O as B,F as E,e as S,B as C,j as T,k as M,f as j,g as O,h as $}from"./p-aIxOGKys.js";import{g as R}from"./p-DiVJyqlX.js";import{e as z,w as I}from"./p-BROiNJRB.js";import{KEYBOARD_DID_OPEN as P}from"./p-9eeaBrnk.js";import{c as L}from"./p-bNmY-WfR.js";import{g as W}from"./p-hHmYLOfE.js";import{createGesture as N}from"./p-Cl0B-RWe.js";import{w as H}from"./p-ZjP4CjeZ.js";import"./p-DzH0J0yi.js";import"./p-BTEOs1at.js";import"./p-D13Eaw-8.js";var V;!function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"}(V||(V={}));const F={getEngine(){const t=A();if(null==t?void 0:t.isPluginAvailable("StatusBar"))return t.Plugins.StatusBar},setStyle(t){const o=this.getEngine();o&&o.setStyle(t)},getStyle:async function(){const t=this.getEngine();if(!t)return V.Default;const{style:o}=await t.getInfo();return o}},K=(t,o)=>{if(1===o)return 0;const a=1/(1-o);return t*a+-o*a},Z=()=>{!H||H.innerWidth>=768||F.setStyle({style:V.Dark})},G=(t=V.Default)=>{!H||H.innerWidth>=768||F.setStyle({style:t})},_=async(t,o)=>{"function"==typeof t.canDismiss&&await t.canDismiss(void 0,D)&&(o.isRunning()?o.onFinish((()=>{t.dismiss(void 0,"handler")}),{oneTimeCallback:!0}):t.dismiss(void 0,"handler"))},X=t=>.00255275*2.71828**(-14.9619*t)-1.00255*2.71828**(-.0380968*t)+1,q=.915,J=(t,o)=>w(400,t/Math.abs(1.1*o),500),U=t=>{const{currentBreakpoint:o,backdropBreakpoint:a,expandToScroll:i}=t,e=void 0===a||a<o,r=e?`calc(var(--backdrop-opacity) * ${o})`:"0",s=L("backdropAnimation").fromTo("opacity",0,r);return e&&s.beforeStyles({"pointer-events":"none"}).afterClearStyles(["pointer-events"]),{wrapperAnimation:L("wrapperAnimation").keyframes([{offset:0,opacity:1,transform:"translateY(100%)"},{offset:1,opacity:1,transform:`translateY(${100-100*o}%)`}]),backdropAnimation:s,contentAnimation:i?void 0:L("contentAnimation").keyframes([{offset:0,opacity:1,maxHeight:100*(1-o)+"%"},{offset:1,opacity:1,maxHeight:100*o+"%"}])}},Q=t=>{const{currentBreakpoint:o,backdropBreakpoint:a}=t,i=`calc(var(--backdrop-opacity) * ${K(o,a)})`,e=[{offset:0,opacity:i},{offset:1,opacity:0}],r=[{offset:0,opacity:i},{offset:a,opacity:0},{offset:1,opacity:0}],s=L("backdropAnimation").keyframes(0!==a?r:e);return{wrapperAnimation:L("wrapperAnimation").keyframes([{offset:0,opacity:1,transform:`translateY(${100-100*o}%)`},{offset:1,opacity:1,transform:"translateY(100%)"}]),backdropAnimation:s}},tt=(t,o)=>{const{presentingEl:a,currentBreakpoint:i,expandToScroll:e}=o,r=v(t),{wrapperAnimation:s,backdropAnimation:n,contentAnimation:d}=void 0!==i?U(o):{backdropAnimation:L().fromTo("opacity",.01,"var(--backdrop-opacity)").beforeStyles({"pointer-events":"none"}).afterClearStyles(["pointer-events"]),wrapperAnimation:L().fromTo("transform","translateY(100vh)","translateY(0vh)"),contentAnimation:void 0};n.addElement(r.querySelector("ion-backdrop")),s.addElement(r.querySelectorAll(".modal-wrapper, .modal-shadow")).beforeStyles({opacity:1}),!e&&(null==d||d.addElement(t.querySelector(".ion-page")));const p=L("entering-base").addElement(t).easing("cubic-bezier(0.32,0.72,0,1)").duration(500).addAnimation([s]);if(d&&p.addAnimation(d),a){const t=window.innerWidth<768,o="ION-MODAL"===a.tagName&&void 0!==a.presentingElement,i=v(a),e=L().beforeStyles({transform:"translateY(0)","transform-origin":"top center",overflow:"hidden"}),r=document.body;if(t){const t=CSS.supports("width","max(0px, 1px)")?"max(30px, var(--ion-safe-area-top))":"30px",i=`translateY(${o?"-10px":t}) scale(0.915)`;e.afterStyles({transform:i}).beforeAddWrite((()=>r.style.setProperty("background-color","black"))).addElement(a).keyframes([{offset:0,filter:"contrast(1)",transform:"translateY(0px) scale(1)",borderRadius:"0px"},{offset:1,filter:"contrast(0.85)",transform:i,borderRadius:"10px 10px 0 0"}]),p.addAnimation(e)}else if(p.addAnimation(n),o){const t=`translateY(-10px) scale(${o?q:1})`;e.afterStyles({transform:t}).addElement(i.querySelector(".modal-wrapper")).keyframes([{offset:0,filter:"contrast(1)",transform:"translateY(0) scale(1)"},{offset:1,filter:"contrast(0.85)",transform:t}]);const a=L().afterStyles({transform:t}).addElement(i.querySelector(".modal-shadow")).keyframes([{offset:0,opacity:"1",transform:"translateY(0) scale(1)"},{offset:1,opacity:"0",transform:t}]);p.addAnimation([e,a])}else s.fromTo("opacity","0","1")}else p.addAnimation(n);return p},ot=(t,o,a=500)=>{const{presentingEl:i,currentBreakpoint:e}=o,r=v(t),{wrapperAnimation:s,backdropAnimation:n}=void 0!==e?Q(o):{backdropAnimation:L().fromTo("opacity","var(--backdrop-opacity)",0),wrapperAnimation:L().fromTo("transform","translateY(0vh)","translateY(100vh)")};n.addElement(r.querySelector("ion-backdrop")),s.addElement(r.querySelectorAll(".modal-wrapper, .modal-shadow")).beforeStyles({opacity:1});const d=L("leaving-base").addElement(t).easing("cubic-bezier(0.32,0.72,0,1)").duration(a).addAnimation(s);if(i){const t=window.innerWidth<768,o="ION-MODAL"===i.tagName&&void 0!==i.presentingElement,a=v(i),e=L().beforeClearStyles(["transform"]).afterClearStyles(["transform"]).onFinish((t=>{1===t&&(i.style.setProperty("overflow",""),Array.from(r.querySelectorAll("ion-modal:not(.overlay-hidden)")).filter((t=>void 0!==t.presentingElement)).length<=1&&r.style.setProperty("background-color",""))})),r=document.body;if(t){const t=CSS.supports("width","max(0px, 1px)")?"max(30px, var(--ion-safe-area-top))":"30px",a=`translateY(${o?"-10px":t}) scale(0.915)`;e.addElement(i).keyframes([{offset:0,filter:"contrast(0.85)",transform:a,borderRadius:"10px 10px 0 0"},{offset:1,filter:"contrast(1)",transform:"translateY(0px) scale(1)",borderRadius:"0px"}]),d.addAnimation(e)}else if(d.addAnimation(n),o){const t=`translateY(-10px) scale(${o?q:1})`;e.addElement(a.querySelector(".modal-wrapper")).afterStyles({transform:"translate3d(0, 0, 0)"}).keyframes([{offset:0,filter:"contrast(0.85)",transform:t},{offset:1,filter:"contrast(1)",transform:"translateY(0) scale(1)"}]);const i=L().addElement(a.querySelector(".modal-shadow")).afterStyles({transform:"translateY(0) scale(1)"}).keyframes([{offset:0,opacity:"0",transform:t},{offset:1,opacity:"1",transform:"translateY(0) scale(1)"}]);d.addAnimation([e,i])}else s.fromTo("opacity","1","0")}else d.addAnimation(n);return d},at=(t,o)=>{const{currentBreakpoint:a,expandToScroll:i}=o,e=v(t),{wrapperAnimation:r,backdropAnimation:s,contentAnimation:n}=void 0!==a?U(o):{backdropAnimation:L().fromTo("opacity",.01,"var(--backdrop-opacity)").beforeStyles({"pointer-events":"none"}).afterClearStyles(["pointer-events"]),wrapperAnimation:L().keyframes([{offset:0,opacity:.01,transform:"translateY(40px)"},{offset:1,opacity:1,transform:"translateY(0px)"}]),contentAnimation:void 0};s.addElement(e.querySelector("ion-backdrop")),r.addElement(e.querySelector(".modal-wrapper")),!i&&(null==n||n.addElement(t.querySelector(".ion-page")));const d=L().addElement(t).easing("cubic-bezier(0.36,0.66,0.04,1)").duration(280).addAnimation([s,r]);return n&&d.addAnimation(n),d},it=(t,o)=>{const{currentBreakpoint:a}=o,i=v(t),{wrapperAnimation:e,backdropAnimation:r}=void 0!==a?Q(o):{backdropAnimation:L().fromTo("opacity","var(--backdrop-opacity)",0),wrapperAnimation:L().keyframes([{offset:0,opacity:.99,transform:"translateY(0px)"},{offset:1,opacity:0,transform:"translateY(40px)"}])};return r.addElement(i.querySelector("ion-backdrop")),e.addElement(i.querySelector(".modal-wrapper")),L().easing("cubic-bezier(0.47,0,0.745,0.715)").duration(200).addAnimation([r,e])},et=class{constructor(a){t(this,a),this.didPresent=o(this,"ionModalDidPresent",7),this.willPresent=o(this,"ionModalWillPresent",7),this.willDismiss=o(this,"ionModalWillDismiss",7),this.didDismiss=o(this,"ionModalDidDismiss",7),this.ionBreakpointDidChange=o(this,"ionBreakpointDidChange",7),this.didPresentShorthand=o(this,"didPresent",7),this.willPresentShorthand=o(this,"willPresent",7),this.willDismissShorthand=o(this,"willDismiss",7),this.didDismissShorthand=o(this,"didDismiss",7),this.ionMount=o(this,"ionMount",7),this.lockController=Y(),this.triggerController=S(),this.coreDelegate=b(),this.isSheetModal=!1,this.inheritedAttributes={},this.inline=!1,this.gestureAnimationDismissing=!1,this.presented=!1,this.hasController=!1,this.keyboardClose=!0,this.expandToScroll=!0,this.backdropBreakpoint=0,this.handleBehavior="none",this.backdropDismiss=!0,this.showBackdrop=!0,this.animated=!0,this.isOpen=!1,this.keepContentsMounted=!1,this.focusTrap=!0,this.canDismiss=!0,this.onHandleClick=()=>{const{sheetTransition:t,handleBehavior:o}=this;"cycle"===o&&void 0===t&&this.moveToNextBreakpoint()},this.onBackdropTap=()=>{const{sheetTransition:t}=this;void 0===t&&this.dismiss(void 0,C)},this.onLifecycle=t=>{const o=this.usersElement,a=rt[t.type];if(o&&a){const i=new CustomEvent(a,{bubbles:!1,cancelable:!1,detail:t.detail});o.dispatchEvent(i)}},this.onModalFocus=t=>{const{dragHandleEl:o,el:a}=this;t.target===a&&o&&-1!==o.tabIndex&&o.focus()}}onIsOpenChange(t,o){!0===t&&!1===o?this.present():!1===t&&!0===o&&this.dismiss()}triggerChanged(){const{trigger:t,el:o,triggerController:a}=this;t&&a.addClickListener(o,t)}onWindowResize(){"ios"!==a(this)||!this.presentingElement||this.enterAnimation||this.leaveAnimation||(clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout((()=>{this.handleViewTransition()}),50))}breakpointsChanged(t){void 0!==t&&(this.sortedBreakpoints=t.sort(((t,o)=>t-o)))}connectedCallback(){const{el:t}=this;T(t),this.triggerChanged()}disconnectedCallback(){this.triggerController.removeClickListener(),this.cleanupViewTransitionListener()}componentWillLoad(){var t;const{breakpoints:o,initialBreakpoint:a,el:e,htmlAttributes:r}=this,s=this.isSheetModal=void 0!==o&&void 0!==a,n=["aria-label","role"];this.inheritedAttributes=k(e,n),void 0!==r&&n.forEach((t=>{r[t]&&(this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:r[t]}),delete r[t])})),s&&(this.currentBreakpoint=this.initialBreakpoint),void 0===o||void 0===a||o.includes(a)||i("[ion-modal] - Your breakpoints array must include the initialBreakpoint value."),(null===(t=this.htmlAttributes)||void 0===t?void 0:t.id)||M(this.el)}componentDidLoad(){!0===this.isOpen&&g((()=>this.present())),this.breakpointsChanged(this.breakpoints),this.triggerChanged()}getDelegate(t=!1){if(this.workingDelegate&&!t)return{delegate:this.workingDelegate,inline:this.inline};const o=this.inline=null!==this.el.parentNode&&!this.hasController;return{inline:o,delegate:this.workingDelegate=o?this.delegate||this.coreDelegate:this.delegate}}async checkCanDismiss(t,o){const{canDismiss:a}=this;return"function"==typeof a?a(t,o):a}async present(){const t=await this.lockController.lock();if(this.presented)return void t();const{presentingElement:o,el:i}=this;this.currentBreakpoint=this.initialBreakpoint;const{inline:r,delegate:s}=this.getDelegate(!0);this.ionMount.emit(),this.usersElement=await u(s,i,this.component,["ion-page"],this.componentProps,r),y(i)?await z(this.usersElement):this.keepContentsMounted||await I(),e((()=>this.el.classList.add("show-modal")));const n=void 0!==o;n&&"ios"===a(this)&&(this.statusBarStyle=await F.getStyle(),Z()),await j(this,"modalEnter",tt,at,{presentingEl:o,currentBreakpoint:this.initialBreakpoint,backdropBreakpoint:this.backdropBreakpoint,expandToScroll:this.expandToScroll}),"undefined"!=typeof window&&(this.keyboardOpenCallback=()=>{this.gesture&&(this.gesture.enable(!1),g((()=>{this.gesture&&this.gesture.enable(!0)})))},window.addEventListener(P,this.keyboardOpenCallback)),this.isSheetModal?this.initSheetGesture():n&&this.initSwipeToClose(),this.initViewTransitionListener(),t()}initSwipeToClose(){var t;if("ios"!==a(this))return;const{el:o}=this,i=this.leaveAnimation||r.get("modalLeave",ot),e=this.animation=i(o,{presentingEl:this.presentingElement,expandToScroll:this.expandToScroll});if(!m(o))return void f(o);const s=null!==(t=this.statusBarStyle)&&void 0!==t?t:V.Default;this.gesture=((t,o,a,i)=>{const e=.5,r=t.offsetHeight;let s=!1,n=!1,d=null,m=null,f=!0,b=0;const u=N({el:t,gestureName:"modalSwipeToClose",gesturePriority:B,direction:"y",threshold:10,canStart:t=>{const o=t.event.target;if(null===o||!o.closest)return!0;if(d=p(o),d){if(l(d)){const t=v(d);m=t.querySelector(".inner-scroll")}else m=d;return!d.querySelector("ion-refresher")&&0===m.scrollTop}return null===o.closest("ion-footer")},onStart:a=>{const{deltaY:i}=a;f=!d||!l(d)||d.scrollY,n=void 0!==t.canDismiss&&!0!==t.canDismiss,i>0&&d&&h(d),o.progressStart(!0,s?1:0)},onMove:t=>{const{deltaY:i}=t;i>0&&d&&h(d);const s=t.deltaY/r,p=s>=0&&n,l=p?.2:.9999,c=p?X(s/l):s,m=w(1e-4,c,l);o.progressStep(m),m>=e&&b<e?G(a):m<e&&b>=e&&Z(),b=m},onEnd:a=>{const p=a.velocityY,l=a.deltaY/r,h=l>=0&&n,m=h?.2:.9999,b=h?X(l/m):l,x=w(1e-4,b,m),v=!h&&(a.deltaY+1e3*p)/r>=e;let g=v?-.001:.001;v?(o.easing("cubic-bezier(0.32, 0.72, 0, 1)"),g+=W([0,0],[.32,.72],[0,1],[1,1],x)[0]):(o.easing("cubic-bezier(1, 0, 0.68, 0.28)"),g+=W([0,0],[1,0],[.68,.28],[1,1],x)[0]);const k=J(v?l*r:(1-x)*r,p);s=v,u.enable(!1),d&&c(d,f),o.onFinish((()=>{v||u.enable(!0)})).progressEnd(v?1:0,g,k),h&&x>m/4?_(t,o):v&&i()}});return u})(o,e,s,(()=>{this.gestureAnimationDismissing=!0,G(this.statusBarStyle),this.animation.onFinish((async()=>{await this.dismiss(void 0,D),this.gestureAnimationDismissing=!1}))})),this.gesture.enable(!0)}initSheetGesture(){const{wrapperEl:t,initialBreakpoint:o,backdropBreakpoint:a}=this;if(!t||void 0===o)return;const i=this.enterAnimation||r.get("modalEnter",tt),e=this.animation=i(this.el,{presentingEl:this.presentingElement,currentBreakpoint:o,backdropBreakpoint:a,expandToScroll:this.expandToScroll});e.progressStart(!0,1);const{gesture:s,moveSheetToBreakpoint:n}=((t,o,a,i,e,r,s=[],n,d,h,c)=>{const m={WRAPPER_KEYFRAMES:[{offset:0,transform:"translateY(0%)"},{offset:1,transform:"translateY(100%)"}],BACKDROP_KEYFRAMES:0!==e?[{offset:0,opacity:"var(--backdrop-opacity)"},{offset:1-e,opacity:0},{offset:1,opacity:0}]:[{offset:0,opacity:"var(--backdrop-opacity)"},{offset:1,opacity:.01}],CONTENT_KEYFRAMES:[{offset:0,maxHeight:"100%"},{offset:1,maxHeight:"0%"}]},f=t.querySelector("ion-content"),b=a.clientHeight;let u=i,x=0,k=!1,y=null,Y=null,A=null,D=null;const B=s[s.length-1],S=s[0],C=r.childAnimations.find((t=>"wrapperAnimation"===t.id)),T=r.childAnimations.find((t=>"backdropAnimation"===t.id)),M=r.childAnimations.find((t=>"contentAnimation"===t.id)),j=()=>{t.style.setProperty("pointer-events","auto"),o.style.setProperty("pointer-events","auto"),t.classList.remove(E)},O=()=>{t.style.setProperty("pointer-events","none"),o.style.setProperty("pointer-events","none"),t.classList.add(E)},$=o=>{if(!Y&&(Y=Array.from(t.querySelectorAll("ion-footer")),!Y.length))return;const a=t.querySelector(".ion-page");if(D=o,"stationary"===o)Y.forEach((t=>{t.classList.remove("modal-footer-moving"),t.style.removeProperty("position"),t.style.removeProperty("width"),t.style.removeProperty("height"),t.style.removeProperty("top"),t.style.removeProperty("left"),null==a||a.style.removeProperty("padding-bottom"),null==a||a.appendChild(t)}));else{let o=0;Y.forEach(((a,i)=>{const e=a.getBoundingClientRect(),r=document.body.getBoundingClientRect();o+=a.clientHeight;const s=e.top-r.top,n=e.left-r.left;if(a.style.setProperty("--pinned-width",`${a.clientWidth}px`),a.style.setProperty("--pinned-height",`${a.clientHeight}px`),a.style.setProperty("--pinned-top",`${s}px`),a.style.setProperty("--pinned-left",`${n}px`),0===i){A=s;const o=t.querySelector("ion-header");o&&(A-=o.clientHeight)}})),Y.forEach((t=>{null==a||a.style.setProperty("padding-bottom",`${o}px`),t.classList.add("modal-footer-moving"),t.style.setProperty("position","absolute"),t.style.setProperty("width","var(--pinned-width)"),t.style.setProperty("height","var(--pinned-height)"),t.style.setProperty("top","var(--pinned-top)"),t.style.setProperty("left","var(--pinned-left)"),document.body.appendChild(t)}))}};C&&T&&(C.keyframes([...m.WRAPPER_KEYFRAMES]),T.keyframes([...m.BACKDROP_KEYFRAMES]),null==M||M.keyframes([...m.CONTENT_KEYFRAMES]),r.progressStart(!0,1-u),u>e?j():O()),f&&u!==B&&n&&(f.scrollY=!1);const R=o=>{const{breakpoint:a,canDismiss:i,breakpointOffset:d,animated:p}=o,l=i&&0===a,b=l?u:a,x=0!==b;return u=0,C&&T&&(C.keyframes([{offset:0,transform:`translateY(${100*d}%)`},{offset:1,transform:`translateY(${100*(1-b)}%)`}]),T.keyframes([{offset:0,opacity:`calc(var(--backdrop-opacity) * ${K(1-d,e)})`},{offset:1,opacity:`calc(var(--backdrop-opacity) * ${K(b,e)})`}]),M&&M.keyframes([{offset:0,maxHeight:100*(1-d)+"%"},{offset:1,maxHeight:100*b+"%"}]),r.progressStep(0)),z.enable(!1),l?_(t,r):x||h(),!f||b!==s[s.length-1]&&n||(f.scrollY=!0),n||0!==b||$("stationary"),new Promise((t=>{r.onFinish((()=>{x?(n||$("stationary"),C&&T?g((()=>{C.keyframes([...m.WRAPPER_KEYFRAMES]),T.keyframes([...m.BACKDROP_KEYFRAMES]),null==M||M.keyframes([...m.CONTENT_KEYFRAMES]),r.progressStart(!0,1-b),u=b,c(u),u>e?j():O(),z.enable(!0),t()})):(z.enable(!0),t())):t()}),{oneTimeCallback:!0}).progressEnd(1,0,p?500:0)}))},z=N({el:a,gestureName:"modalSheet",gesturePriority:40,direction:"y",threshold:10,canStart:t=>{const o=p(t.event.target);if(u=d(),!n&&o)return 0===(l(o)?v(o).querySelector(".inner-scroll"):o).scrollTop;if(1===u&&o){const t=l(o)?v(o).querySelector(".inner-scroll"):o;return!o.querySelector("ion-refresher")&&0===t.scrollTop}return!0},onStart:o=>{if(k=void 0!==t.canDismiss&&!0!==t.canDismiss&&0===S,!n){const t=p(o.event.target);y=t&&l(t)?v(t).querySelector(".inner-scroll"):t}n||$("moving"),o.deltaY>0&&f&&(f.scrollY=!1),g((()=>{t.focus()})),r.progressStart(!0,1-u)},onMove:t=>{if(n||null===A||null===D||(t.currentY>=A&&"moving"===D?$("stationary"):t.currentY<A&&"stationary"===D&&$("moving")),!n&&t.deltaY<=0&&y)return;t.deltaY>0&&f&&(f.scrollY=!1);const o=s.length>1?1-s[1]:void 0,a=1-u+t.deltaY/b,i=void 0!==o&&a>=o&&k,e=i?.95:.9999,d=i&&void 0!==o?o+X((a-o)/(e-o)):a;x=w(1e-4,d,e),r.progressStep(x)},onEnd:t=>{if(!n&&t.deltaY<=0&&y&&y.scrollTop>0)return void $("stationary");const o=u-(t.deltaY+350*t.velocityY)/b,a=s.reduce(((t,a)=>Math.abs(a-o)<Math.abs(t-o)?a:t));R({breakpoint:a,breakpointOffset:x,canDismiss:k,animated:!0})}});return{gesture:z,moveSheetToBreakpoint:R}})(this.el,this.backdropEl,t,o,a,e,this.sortedBreakpoints,this.expandToScroll,(()=>{var t;return null!==(t=this.currentBreakpoint)&&void 0!==t?t:0}),(()=>this.sheetOnDismiss()),(t=>{this.currentBreakpoint!==t&&(this.currentBreakpoint=t,this.ionBreakpointDidChange.emit({breakpoint:t}))}));this.gesture=s,this.moveSheetToBreakpoint=n,this.gesture.enable(!0)}sheetOnDismiss(){this.gestureAnimationDismissing=!0,this.animation.onFinish((async()=>{this.currentBreakpoint=0,this.ionBreakpointDidChange.emit({breakpoint:this.currentBreakpoint}),await this.dismiss(void 0,D),this.gestureAnimationDismissing=!1}))}async dismiss(t,o){var i;if(this.gestureAnimationDismissing&&o!==D)return!1;const r=await this.lockController.lock();if("handler"!==o&&!await this.checkCanDismiss(t,o))return r(),!1;const{presentingElement:s}=this;void 0!==s&&"ios"===a(this)&&G(this.statusBarStyle),"undefined"!=typeof window&&this.keyboardOpenCallback&&(window.removeEventListener(P,this.keyboardOpenCallback),this.keyboardOpenCallback=void 0);const n=await O(this,t,o,"modalLeave",ot,it,{presentingEl:s,currentBreakpoint:null!==(i=this.currentBreakpoint)&&void 0!==i?i:this.initialBreakpoint,backdropBreakpoint:this.backdropBreakpoint,expandToScroll:this.expandToScroll});if(n){const{delegate:t}=this.getDelegate();await x(t,this.usersElement),e((()=>this.el.classList.remove("show-modal"))),this.animation&&this.animation.destroy(),this.gesture&&this.gesture.destroy(),this.cleanupViewTransitionListener()}return this.currentBreakpoint=void 0,this.animation=void 0,r(),n}onDidDismiss(){return $(this.el,"ionModalDidDismiss")}onWillDismiss(){return $(this.el,"ionModalWillDismiss")}async setCurrentBreakpoint(t){if(!this.isSheetModal)return void i("[ion-modal] - setCurrentBreakpoint is only supported on sheet modals.");if(!this.breakpoints.includes(t))return void i(`[ion-modal] - Attempted to set invalid breakpoint value ${t}. Please double check that the breakpoint value is part of your defined breakpoints.`);const{currentBreakpoint:o,moveSheetToBreakpoint:a,canDismiss:e,breakpoints:r,animated:s}=this;o!==t&&a&&(this.sheetTransition=a({breakpoint:t,breakpointOffset:1-o,canDismiss:void 0!==e&&!0!==e&&0===r[0],animated:s}),await this.sheetTransition,this.sheetTransition=void 0)}async getCurrentBreakpoint(){return this.currentBreakpoint}async moveToNextBreakpoint(){const{breakpoints:t,currentBreakpoint:o}=this;if(!t||null==o)return!1;const a=t.filter((t=>0!==t)),i=a.indexOf(o),e=a[(i+1)%a.length];return await this.setCurrentBreakpoint(e),!0}initViewTransitionListener(){"ios"!==a(this)||!this.presentingElement||this.enterAnimation||this.leaveAnimation||(this.currentViewIsPortrait=window.innerWidth<768)}handleViewTransition(){const t=window.innerWidth<768;if(this.currentViewIsPortrait===t)return;this.viewTransitionAnimation&&(this.viewTransitionAnimation.destroy(),this.viewTransitionAnimation=void 0);const{presentingElement:o}=this;if(!o)return;let a;a=this.currentViewIsPortrait&&!t?((t,o,a=300)=>{const{presentingEl:i}=o;if(!i)return L("portrait-to-landscape-transition");const e="ION-MODAL"===i.tagName&&void 0!==i.presentingElement,r=v(i),s=document.body,n=L("portrait-to-landscape-transition").addElement(t).easing("cubic-bezier(0.32,0.72,0,1)").duration(a),d=L().beforeStyles({transform:"translateY(0)","transform-origin":"top center",overflow:"hidden"});if(e){const t="translateY(-10px) scale(0.915)",o="translateY(-10px) scale(0.915)";d.addElement(r.querySelector(".modal-wrapper")).afterStyles({transform:o}).fromTo("transform",t,o).fromTo("filter","contrast(0.85)","contrast(0.85)");const a=L().addElement(r.querySelector(".modal-shadow")).afterStyles({transform:o}).fromTo("opacity","0","0").fromTo("transform",t,o);n.addAnimation([d,a])}else{const o=v(t),a=L().addElement(o.querySelectorAll(".modal-wrapper, .modal-shadow")).fromTo("opacity","1","1"),e=L().addElement(o.querySelector("ion-backdrop")).fromTo("opacity","var(--backdrop-opacity)","var(--backdrop-opacity)"),r=`translateY(${CSS.supports("width","max(0px, 1px)")?"max(30px, var(--ion-safe-area-top))":"30px"}) scale(0.915)`;d.addElement(i).afterStyles({transform:"translateY(0px) scale(1)","border-radius":"0px"}).beforeAddWrite((()=>s.style.setProperty("background-color",""))).fromTo("transform",r,"translateY(0px) scale(1)").fromTo("filter","contrast(0.85)","contrast(1)").fromTo("border-radius","10px 10px 0 0","0px"),n.addAnimation([d,a,e])}return n})(this.el,{presentingEl:o}):((t,o,a=300)=>{const{presentingEl:i}=o;if(!i)return L("landscape-to-portrait-transition");const e="ION-MODAL"===i.tagName&&void 0!==i.presentingElement,r=v(i),s=document.body,n=L("landscape-to-portrait-transition").addElement(t).easing("cubic-bezier(0.32,0.72,0,1)").duration(a),d=L().beforeStyles({transform:"translateY(0)","transform-origin":"top center",overflow:"hidden"});if(e){const t="translateY(-10px) scale(0.915)",o="translateY(-10px) scale(0.915)";d.addElement(r.querySelector(".modal-wrapper")).afterStyles({transform:o}).fromTo("transform",t,o).fromTo("filter","contrast(0.85)","contrast(0.85)");const a=L().addElement(r.querySelector(".modal-shadow")).afterStyles({transform:o}).fromTo("opacity","0","0").fromTo("transform",t,o);n.addAnimation([d,a])}else{const o=v(t),a=L().addElement(o.querySelectorAll(".modal-wrapper, .modal-shadow")).fromTo("opacity","1","1"),e=L().addElement(o.querySelector("ion-backdrop")).fromTo("opacity","var(--backdrop-opacity)","var(--backdrop-opacity)"),r=`translateY(${CSS.supports("width","max(0px, 1px)")?"max(30px, var(--ion-safe-area-top))":"30px"}) scale(0.915)`;d.addElement(i).beforeStyles({transform:"translateY(0px) scale(1)","transform-origin":"top center",overflow:"hidden"}).afterStyles({transform:r,"border-radius":"10px 10px 0 0",filter:"contrast(0.85)",overflow:"hidden","transform-origin":"top center"}).beforeAddWrite((()=>s.style.setProperty("background-color","black"))).keyframes([{offset:0,transform:"translateY(0px) scale(1)",filter:"contrast(1)",borderRadius:"0px"},{offset:.2,transform:"translateY(0px) scale(1)",filter:"contrast(1)",borderRadius:"10px 10px 0 0"},{offset:1,transform:r,filter:"contrast(0.85)",borderRadius:"10px 10px 0 0"}]),n.addAnimation([d,a,e])}return n})(this.el,{presentingEl:o}),this.currentViewIsPortrait=t,this.viewTransitionAnimation=a,a.play().then((()=>{this.viewTransitionAnimation=void 0,this.reinitSwipeToClose()}))}cleanupViewTransitionListener(){this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=void 0),this.viewTransitionAnimation&&(this.viewTransitionAnimation.destroy(),this.viewTransitionAnimation=void 0)}reinitSwipeToClose(){"ios"===a(this)&&this.presentingElement&&(this.gesture&&(this.gesture.destroy(),this.gesture=void 0),this.animation&&(this.animation.progressEnd(0,0,0),this.animation.destroy(),this.animation=void 0),g((()=>{this.ensureCorrectModalPosition(),this.initSwipeToClose()})))}ensureCorrectModalPosition(){const{el:t,presentingElement:o}=this,a=v(t).querySelector(".modal-wrapper");if(a&&(a.style.transform="translateY(0vh)",a.style.opacity="1"),o)if(window.innerWidth<768){const t=CSS.supports("width","max(0px, 1px)")?"max(30px, var(--ion-safe-area-top))":"30px";o.style.transform=`translateY(${t}) scale(0.915)`}else o.style.transform="translateY(0px) scale(1)"}render(){const{handle:t,isSheetModal:o,presentingElement:i,htmlAttributes:e,handleBehavior:r,inheritedAttributes:d,focusTrap:p,expandToScroll:l}=this,h=!1!==t&&o,c=a(this),m=void 0!==i&&"ios"===c,f="cycle"===r;return s(n,Object.assign({key:"1980fa23331381c568a2be8091d888e09754fc52","no-router":!0,tabIndex:f&&o&&h?0:-1},e,{style:{zIndex:`${2e4+this.overlayIndex}`},class:Object.assign({[c]:!0,"modal-default":!m&&!o,"modal-card":m,"modal-sheet":o,"modal-no-expand-scroll":o&&!l,"overlay-hidden":!0,[E]:!1===p},R(this.cssClass)),onIonBackdropTap:this.onBackdropTap,onIonModalDidPresent:this.onLifecycle,onIonModalWillPresent:this.onLifecycle,onIonModalWillDismiss:this.onLifecycle,onIonModalDidDismiss:this.onLifecycle,onFocus:this.onModalFocus}),s("ion-backdrop",{key:"ba94b055c064e2907eabbe6d7a43cb52adff1048",ref:t=>this.backdropEl=t,visible:this.showBackdrop,tappable:this.backdropDismiss,part:"backdrop"}),"ios"===c&&s("div",{key:"991f47859250d2143275ebb9b0b01a6ea8c491c0",class:"modal-shadow"}),s("div",Object.assign({key:"02ecf8ac6a5bdb309ff993cc74a3911e99502a89",role:"dialog"},d,{"aria-modal":"true",class:"modal-wrapper ion-overlay-wrapper",part:"content",ref:t=>this.wrapperEl=t}),h&&s("button",{key:"0180a4d6952e41bfd736272d1a49d47d86ca7fef",class:"modal-handle",tabIndex:f?0:-1,"aria-label":"Activate to adjust the size of the dialog overlaying the screen",onClick:f?this.onHandleClick:void 0,part:"handle",ref:t=>this.dragHandleEl=t}),s("slot",{key:"d062f330675f730ad70c23267baed200ca9b43b0"})))}get el(){return d(this)}static get watchers(){return{isOpen:["onIsOpenChange"],trigger:["triggerChanged"]}}},rt={ionModalDidPresent:"ionViewDidEnter",ionModalWillPresent:"ionViewWillEnter",ionModalWillDismiss:"ionViewWillLeave",ionModalDidDismiss:"ionViewDidLeave"};et.style={ios:':host{--width:100%;--min-width:auto;--max-width:auto;--height:100%;--min-height:auto;--max-height:auto;--overflow:hidden;--border-radius:0;--border-width:0;--border-style:none;--border-color:transparent;--background:var(--ion-background-color, #fff);--box-shadow:none;--backdrop-opacity:0;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;color:var(--ion-text-color, #000);contain:strict}.modal-wrapper,ion-backdrop{pointer-events:auto}:host(.overlay-hidden){display:none}.modal-wrapper,.modal-shadow{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);overflow:var(--overflow);z-index:10}.modal-shadow{position:absolute;background:transparent}@media only screen and (min-width: 768px) and (min-height: 600px){:host{--width:600px;--height:500px;--ion-safe-area-top:0px;--ion-safe-area-bottom:0px;--ion-safe-area-right:0px;--ion-safe-area-left:0px}}@media only screen and (min-width: 768px) and (min-height: 768px){:host{--width:600px;--height:600px}}.modal-handle{left:0px;right:0px;top:5px;border-radius:8px;-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;position:absolute;width:36px;height:5px;-webkit-transform:translateZ(0);transform:translateZ(0);border:0;background:var(--ion-color-step-350, var(--ion-background-color-step-350, #c0c0be));cursor:pointer;z-index:11}.modal-handle::before{-webkit-padding-start:4px;padding-inline-start:4px;-webkit-padding-end:4px;padding-inline-end:4px;padding-top:4px;padding-bottom:4px;position:absolute;width:36px;height:5px;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);content:""}:host(.modal-sheet){--height:calc(100% - (var(--ion-safe-area-top) + 10px))}:host(.modal-sheet) .modal-wrapper,:host(.modal-sheet) .modal-shadow{position:absolute;bottom:0}:host(.modal-sheet.modal-no-expand-scroll) ion-footer{position:absolute;bottom:0;width:var(--width)}:host{--backdrop-opacity:var(--ion-backdrop-opacity, 0.4)}:host(.modal-card),:host(.modal-sheet){--border-radius:10px}@media only screen and (min-width: 768px) and (min-height: 600px){:host{--border-radius:10px}}.modal-wrapper{-webkit-transform:translate3d(0, 100%, 0);transform:translate3d(0, 100%, 0)}@media screen and (max-width: 767px){@supports (width: max(0px, 1px)){:host(.modal-card){--height:calc(100% - max(30px, var(--ion-safe-area-top)) - 10px)}}@supports not (width: max(0px, 1px)){:host(.modal-card){--height:calc(100% - 40px)}}:host(.modal-card) .modal-wrapper{border-start-start-radius:var(--border-radius);border-start-end-radius:var(--border-radius);border-end-end-radius:0;border-end-start-radius:0}:host(.modal-card){--backdrop-opacity:0;--width:100%;-ms-flex-align:end;align-items:flex-end}:host(.modal-card) .modal-shadow{display:none}:host(.modal-card) ion-backdrop{pointer-events:none}}@media screen and (min-width: 768px){:host(.modal-card){--width:calc(100% - 120px);--height:calc(100% - (120px + var(--ion-safe-area-top) + var(--ion-safe-area-bottom)));--max-width:720px;--max-height:1000px;--backdrop-opacity:0;--box-shadow:0px 0px 30px 10px rgba(0, 0, 0, 0.1);-webkit-transition:all 0.5s ease-in-out;transition:all 0.5s ease-in-out}:host(.modal-card) .modal-wrapper{-webkit-box-shadow:none;box-shadow:none}:host(.modal-card) .modal-shadow{-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}}:host(.modal-sheet) .modal-wrapper{border-start-start-radius:var(--border-radius);border-start-end-radius:var(--border-radius);border-end-end-radius:0;border-end-start-radius:0}',md:':host{--width:100%;--min-width:auto;--max-width:auto;--height:100%;--min-height:auto;--max-height:auto;--overflow:hidden;--border-radius:0;--border-width:0;--border-style:none;--border-color:transparent;--background:var(--ion-background-color, #fff);--box-shadow:none;--backdrop-opacity:0;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;color:var(--ion-text-color, #000);contain:strict}.modal-wrapper,ion-backdrop{pointer-events:auto}:host(.overlay-hidden){display:none}.modal-wrapper,.modal-shadow{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);overflow:var(--overflow);z-index:10}.modal-shadow{position:absolute;background:transparent}@media only screen and (min-width: 768px) and (min-height: 600px){:host{--width:600px;--height:500px;--ion-safe-area-top:0px;--ion-safe-area-bottom:0px;--ion-safe-area-right:0px;--ion-safe-area-left:0px}}@media only screen and (min-width: 768px) and (min-height: 768px){:host{--width:600px;--height:600px}}.modal-handle{left:0px;right:0px;top:5px;border-radius:8px;-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;position:absolute;width:36px;height:5px;-webkit-transform:translateZ(0);transform:translateZ(0);border:0;background:var(--ion-color-step-350, var(--ion-background-color-step-350, #c0c0be));cursor:pointer;z-index:11}.modal-handle::before{-webkit-padding-start:4px;padding-inline-start:4px;-webkit-padding-end:4px;padding-inline-end:4px;padding-top:4px;padding-bottom:4px;position:absolute;width:36px;height:5px;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);content:""}:host(.modal-sheet){--height:calc(100% - (var(--ion-safe-area-top) + 10px))}:host(.modal-sheet) .modal-wrapper,:host(.modal-sheet) .modal-shadow{position:absolute;bottom:0}:host(.modal-sheet.modal-no-expand-scroll) ion-footer{position:absolute;bottom:0;width:var(--width)}:host{--backdrop-opacity:var(--ion-backdrop-opacity, 0.32)}@media only screen and (min-width: 768px) and (min-height: 600px){:host{--border-radius:2px;--box-shadow:0 28px 48px rgba(0, 0, 0, 0.4)}}.modal-wrapper{-webkit-transform:translate3d(0, 40px, 0);transform:translate3d(0, 40px, 0);opacity:0.01}'};export{et as ion_modal}