text: import { r as registerInstance, d as getIonMode, c as createEvent, h, e as getElement, H as Host } from './chunk-f257aad1.js';
  import './chunk-1074393c.js';
  import './chunk-94c4865f.js';
  import { B as BACKDROP, d as present, e as dismiss, f as eventMethod } from './chunk-24212d31.js';
  import { g as getClassMap } from './chunk-9d21e8e5.js';
  import { a as attachComponent, d as detachComponent } from './chunk-25340090.js';
  import { d as deepReady } from './chunk-815c1888.js';
  
  /**
   * iOS Modal Enter Animation
   */
  function iosEnterAnimation(AnimationC, baseEl) {
      const baseAnimation = new AnimationC();
      const backdropAnimation = new AnimationC();
      backdropAnimation.addElement(baseEl.querySelector('ion-backdrop'));
      const wrapperAnimation = new AnimationC();
      wrapperAnimation.addElement(baseEl.querySelector('.modal-wrapper'));
      wrapperAnimation.beforeStyles({ 'opacity': 1 })
          .fromTo('translateY', '100%', '0%');
      backdropAnimation.fromTo('opacity', 0.01, 0.4);
      return Promise.resolve(baseAnimation
          .addElement(baseEl)
          .easing('cubic-bezier(0.36,0.66,0.04,1)')
          .duration(400)
          .beforeAddClass('show-modal')
          .add(backdropAnimation)
          .add(wrapperAnimation));
  }
  /**
   * Animations for modals
   */
  // export function modalSlideIn(rootEl: HTMLElement) {
  // }
  // export class ModalSlideOut {
  //   constructor(el: HTMLElement) {
  //     let backdrop = new Animation(this.plt, el.querySelector('ion-backdrop'));
  //     let wrapperEle = <HTMLElement>el.querySelector('.modal-wrapper');
  //     let wrapperEleRect = wrapperEle.getBoundingClientRect();
  //     let wrapper = new Animation(this.plt, wrapperEle);
  //     // height of the screen - top of the container tells us how much to scoot it down
  //     // so it's off-screen
  //     wrapper.fromTo('translateY', '0px', `${this.plt.height() - wrapperEleRect.top}px`);
  //     backdrop.fromTo('opacity', 0.4, 0.0);
  //     this
  //       .element(this.leavingView.pageRef())
  //       .easing('ease-out')
  //       .duration(250)
  //       .add(backdrop)
  //       .add(wrapper);
  //   }
  // }
  // export class ModalMDSlideIn {
  //   constructor(el: HTMLElement) {
  //     const backdrop = new Animation(this.plt, el.querySelector('ion-backdrop'));
  //     const wrapper = new Animation(this.plt, el.querySelector('.modal-wrapper'));
  //     backdrop.fromTo('opacity', 0.01, 0.4);
  //     wrapper.fromTo('translateY', '40px', '0px');
  //     wrapper.fromTo('opacity', 0.01, 1);
  //     const DURATION = 280;
  //     const EASING = 'cubic-bezier(0.36,0.66,0.04,1)';
  //     this.element(this.enteringView.pageRef()).easing(EASING).duration(DURATION)
  //       .add(backdrop)
  //       .add(wrapper);
  //   }
  // }
  // export class ModalMDSlideOut {
  //   constructor(el: HTMLElement) {
  //     const backdrop = new Animation(this.plt, el.querySelector('ion-backdrop'));
  //     const wrapper = new Animation(this.plt, el.querySelector('.modal-wrapper'));
  //     backdrop.fromTo('opacity', 0.4, 0.0);
  //     wrapper.fromTo('translateY', '0px', '40px');
  //     wrapper.fromTo('opacity', 0.99, 0);
  //     this
  //       .element(this.leavingView.pageRef())
  //       .duration(200)
  //       .easing('cubic-bezier(0.47,0,0.745,0.715)')
  //       .add(wrapper)
  //       .add(backdrop);
  //   }
  // }
  
  /**
   * iOS Modal Leave Animation
   */
  function iosLeaveAnimation(AnimationC, baseEl) {
      const baseAnimation = new AnimationC();
      const backdropAnimation = new AnimationC();
      backdropAnimation.addElement(baseEl.querySelector('ion-backdrop'));
      const wrapperAnimation = new AnimationC();
      const wrapperEl = baseEl.querySelector('.modal-wrapper');
      wrapperAnimation.addElement(wrapperEl);
      const wrapperElRect = wrapperEl.getBoundingClientRect();
      wrapperAnimation.beforeStyles({ 'opacity': 1 })
          .fromTo('translateY', '0%', `${baseEl.ownerDocument.defaultView.innerHeight - wrapperElRect.top}px`);
      backdropAnimation.fromTo('opacity', 0.4, 0.0);
      return Promise.resolve(baseAnimation
          .addElement(baseEl)
          .easing('ease-out')
          .duration(250)
          .add(backdropAnimation)
          .add(wrapperAnimation));
  }
  
  /**
   * Md Modal Enter Animation
   */
  function mdEnterAnimation(AnimationC, baseEl) {
      const baseAnimation = new AnimationC();
      const backdropAnimation = new AnimationC();
      backdropAnimation.addElement(baseEl.querySelector('ion-backdrop'));
      const wrapperAnimation = new AnimationC();
      wrapperAnimation.addElement(baseEl.querySelector('.modal-wrapper'));
      wrapperAnimation
          .fromTo('opacity', 0.01, 1)
          .fromTo('translateY', '40px', '0px');
      backdropAnimation.fromTo('opacity', 0.01, 0.32);
      return Promise.resolve(baseAnimation
          .addElement(baseEl)
          .easing('cubic-bezier(0.36,0.66,0.04,1)')
          .duration(280)
          .beforeAddClass('show-modal')
          .add(backdropAnimation)
          .add(wrapperAnimation));
  }
  
  /**
   * Md Modal Leave Animation
   */
  function mdLeaveAnimation(AnimationC, baseEl) {
      const baseAnimation = new AnimationC();
      const backdropAnimation = new AnimationC();
      backdropAnimation.addElement(baseEl.querySelector('ion-backdrop'));
      const wrapperAnimation = new AnimationC();
      const wrapperEl = baseEl.querySelector('.modal-wrapper');
      wrapperAnimation.addElement(wrapperEl);
      wrapperAnimation
          .fromTo('opacity', 0.99, 0)
          .fromTo('translateY', '0px', '40px');
      backdropAnimation.fromTo('opacity', 0.32, 0.0);
      return Promise.resolve(baseAnimation
          .addElement(baseEl)
          .easing('cubic-bezier(0.47,0,0.745,0.715)')
          .duration(200)
          .add(backdropAnimation)
          .add(wrapperAnimation));
  }
  
  /**
   * @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
   */
  class Modal {
      constructor(hostRef) {
          registerInstance(this, hostRef);
          this.presented = false;
          this.mode = getIonMode(this);
          /**
           * If `true`, the keyboard will be automatically dismissed when the overlay is presented.
           */
          this.keyboardClose = true;
          /**
           * If `true`, the modal will be dismissed when the backdrop is clicked.
           */
          this.backdropDismiss = true;
          /**
           * If `true`, a backdrop will be displayed behind the modal.
           */
          this.showBackdrop = true;
          /**
           * If `true`, the modal will animate.
           */
          this.animated = true;
          this.didPresent = createEvent(this, "ionModalDidPresent", 7);
          this.willPresent = createEvent(this, "ionModalWillPresent", 7);
          this.willDismiss = createEvent(this, "ionModalWillDismiss", 7);
          this.didDismiss = createEvent(this, "ionModalDidDismiss", 7);
      }
      onDismiss(ev) {
          ev.stopPropagation();
          ev.preventDefault();
          this.dismiss();
      }
      onBackdropTap() {
          this.dismiss(undefined, BACKDROP);
      }
      lifecycle(modalEvent) {
          const el = this.usersElement;
          const name = LIFECYCLE_MAP[modalEvent.type];
          if (el && name) {
              const ev = new CustomEvent(name, {
                  bubbles: false,
                  cancelable: false,
                  detail: modalEvent.detail
              });
              el.dispatchEvent(ev);
          }
      }
      /**
       * Present the modal overlay after it has been created.
       */
      async present() {
          if (this.presented) {
              return;
          }
          const container = this.el.querySelector(`.modal-wrapper`);
          if (!container) {
              throw new Error('container is undefined');
          }
          const componentProps = Object.assign({}, this.componentProps, { modal: this.el });
          this.usersElement = await attachComponent(this.delegate, container, this.component, ['ion-page'], componentProps);
          await deepReady(this.usersElement);
          return present(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation);
      }
      /**
       * Dismiss the modal overlay after it has been presented.
       *
       * @param data Any data to emit in the dismiss events.
       * @param role The role of the element that is dismissing the modal. For example, 'cancel' or 'backdrop'.
       */
      async dismiss(data, role) {
          const dismissed = await dismiss(this, data, role, 'modalLeave', iosLeaveAnimation, mdLeaveAnimation);
          if (dismissed) {
              await detachComponent(this.delegate, this.usersElement);
          }
          return dismissed;
      }
      /**
       * Returns a promise that resolves when the modal did dismiss.
       */
      onDidDismiss() {
          return eventMethod(this.el, 'ionModalDidDismiss');
      }
      /**
       * Returns a promise that resolves when the modal will dismiss.
       */
      onWillDismiss() {
          return eventMethod(this.el, 'ionModalWillDismiss');
      }
      hostData() {
          const mode = getIonMode(this);
          return {
              'no-router': true,
              'aria-modal': 'true',
              class: Object.assign({ [mode]: true }, getClassMap(this.cssClass)),
              style: {
                  zIndex: 20000 + this.overlayIndex,
              }
          };
      }
      __stencil_render() {
          const mode = getIonMode(this);
          const dialogClasses = {
              [`modal-wrapper`]: true,
              [mode]: true,
          };
          return [
              h("ion-backdrop", { visible: this.showBackdrop, tappable: this.backdropDismiss }),
              h("div", { role: "dialog", class: dialogClasses })
          ];
      }
      get el() { return getElement(this); }
      render() { return h(Host, this.hostData(), this.__stencil_render()); }
      static get style() { return ".sc-ion-modal-md-h{--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;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;contain:strict}.overlay-hidden.sc-ion-modal-md-h{display:none}.modal-wrapper.sc-ion-modal-md{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}\@media only screen and (min-width:768px) and (min-height:600px){.sc-ion-modal-md-h{--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){.sc-ion-modal-md-h{--width:600px;--height:600px}}\@media only screen and (min-width:768px) and (min-height:600px){.sc-ion-modal-md-h{--border-radius:2px;--box-shadow:0 28px 48px rgba(0,0,0,0.4)}}.modal-wrapper.sc-ion-modal-md{-webkit-transform:translate3d(0,40px,0);transform:translate3d(0,40px,0);opacity:.01}"; }
  }
  const LIFECYCLE_MAP = {
      'ionModalDidPresent': 'ionViewDidEnter',
      'ionModalWillPresent': 'ionViewWillEnter',
      'ionModalWillDismiss': 'ionViewWillLeave',
      'ionModalDidDismiss': 'ionViewDidLeave',
  };
  
  export { Modal as ion_modal };
  