import*as t from"lit/directives/style-map.js";import*as e from"lit";import*as o from"@momentum-ui/utils/lib/getColorValue";import*as a from"lit/directives/if-defined.js";import*as i from"lit/directives/class-map.js";import*as s from"mobx";import*as r from"lit/decorators.js";import*as n from"@momentum-ui/icons/data/momentumUiIconsNames.json";var l,d,p={329(t,e,o){o.d(e,{PG:()=>v,aF:()=>y,o6:()=>u}),o(5983),o(1821);var a=o(2900),i=o(3876),s=o(7704),r=o(9609),n=o(4084),l=o(2927),d=o(8899),p=o(4955),m=o(3517),h=o(6005),c=function(t,e,o,a){var i,s=arguments.length,r=s<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,o):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,a);else for(var n=t.length-1;n>=0;n--)(i=t[n])&&(r=(s<3?i(r):s>3?i(e,o,r):i(e,o))||r);return s>3&&r&&Object.defineProperty(e,o,r),r};const u=["default","full","large","small","dialog"],v=["leading","center"];var y;!function(t){let e=class extends((0,s.dY)(l.LitElement)){constructor(){super(...arguments),this.show=!1,this.headerLabel="",this.headerMessage="",this.htmlId="",this.ariaLabel="modal",this.ariaLabelClose="Close Modal",this.ariaLabelCancel="Cancel Modal",this.ariaLabelSubmit="Submit Modal",this.ariaDescription="",this.showCloseButton=!1,this.backdropClickExit=!1,this.noExitOnEsc=!1,this.size="default",this.closeBtnName="",this.hideFooter=!1,this.hideHeader=!1,this.disableInitialFocus=!1,this.alignment=void 0,this.animating=!1,this.handleCloseOutside=t=>{t.code===a.Uz.Escape&&(t.preventDefault(),this.show&&!this.noExitOnEsc&&(this.show=!1))}}static get styles(){return[n.A,h.A]}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleCloseOutside)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleCloseOutside)}update(t){super.update(t),t.has("show")&&(this.show?this.modalFadeIn():!0===t.get("show")&&this.modalFadeOut())}get computedAlignment(){return void 0===this.alignment?i.vz.isMomentumV2Enabled?"leading":"center":this.alignment}notifyModalClose(){this.dispatchEvent(new CustomEvent("close-modal",{composed:!0,bubbles:!0}))}focusInsideModal(){var t;(null===(t=this.focusableElements)||void 0===t?void 0:t.length)&&this.setInitialFocus()}handleKeyDown(t){t.code!==a.Uz.Enter&&t.code!==a.Uz.Space||this.show&&(this.show=!0)}transitionPromise(t){return new Promise(e=>{const o=()=>{t.removeEventListener("transitionend",o),this.activateFocusTrap(),this.setFocusableElements(),requestAnimationFrame(()=>{e()})},a=()=>{t.removeEventListener("transitioncancel",a),this.deactivateFocusTrap(),this.modalFadeOut(),e()};t.addEventListener("transitionend",o),t.addEventListener("transitioncancel",a),setTimeout(()=>{this.animating=!0},13)})}modalFadeIn(){return t=this,e=void 0,a=function*(){this.backDrop&&(yield this.transitionPromise(this.backDrop),this.disableInitialFocus||this.focusInsideModal())},new((o=void 0)||(o=Promise))(function(i,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function n(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(r,n)}l((a=a.apply(t,e||[])).next())});var t,e,o,a}modalFadeOut(){this.animating=!1,this.deactivateFocusTrap(),this.notifyModalClose()}handleCloseBackdrop(){this.backdropClickExit&&(this.show=!1)}hideModal(){this.animating=!1,this.show=!1}topCloseBtnTemplate(){return l.html`
        ${this.showCloseButton?l.html`
              <md-button
                variant="ghost"
                size="20"
                circle
                class="md-close md-modal__close"
                @click=${this.hideModal}
                @keydown=${this.handleKeyDown}
                ariaLabel=${this.ariaLabelClose}
              >
                <md-icon name="cancel-bold" size="16" iconSet="momentumDesign"></md-icon>
              </md-button>
            `:l.nothing}
      `}handleFooterClick(){this.show=!1}headerTemplate(){return this.hideHeader?l.html`
            <div id="modal_header" part="modal-header" class="md-modal__header">
              <slot name="header"></slot>
            </div>
          `:l.html`
            <div id="modal_header" part="modal-header" class="md-modal__header">
              <h2 class="md-modal__title">${this.headerLabel}</h2>
              ${this.headerMessage?l.html` <span class="md-modal__message">${this.headerMessage}</span> `:l.nothing}
            </div>
          `}footerTemplate(){return this.hideFooter?l.html`
            <div part="modal-footer" class="md-modal__footer">
              <slot name="footer"></slot>
            </div>
          `:l.html`
            <div part="modal-footer" class="md-modal__footer">
              <md-button
                aria-label=${this.ariaLabelCancel}
                @click=${this.handleFooterClick}
                @keydown=${this.handleKeyDown}
                variant="secondary"
              >
                <span>Cancel</span>
              </md-button>
              <md-button
                type="submit"
                variant="primary"
                aria-label=${this.ariaLabelSubmit}
                @click=${this.handleFooterClick}
                @keydown=${this.handleKeyDown}
              >
                <span>${this.closeBtnName}</span>
              </md-button>
            </div>
          `}get modalBackDropClassMap(){return{in:this.show&&this.animating}}get modalContainerClassMap(){return{in:this.show,[`md-modal--${this.size}`]:!!this.size,[`md-modal--${this.computedAlignment}`]:!!this.computedAlignment}}render(){return l.html`
        ${this.show?l.html`
              <div part="modal-backdrop" class="md-modal__backdrop fade ${(0,p.classMap)(this.modalBackDropClassMap)}">
                ${this.backdropClickExit?l.html` <div class="md-modal_overlay" @click=${this.handleCloseBackdrop}></div> `:l.nothing}

                <div
                  part="modal-container"
                  role="dialog"
                  id="${this.htmlId}"
                  class="md-modal ${(0,p.classMap)(this.modalContainerClassMap)}"
                  aria-label="${(0,m.ifDefined)(this.headerLabel||this.ariaLabel||void 0)}"
                  aria-describedby=${(0,m.ifDefined)(this.ariaDescription||void 0)}
                >
                  <div part="modal-content" class="md-modal__content">
                    <div class="md-modal__flex-container" part="modal-flex-container">
                      ${this.headerTemplate()} ${this.topCloseBtnTemplate()}
                      <div id="modal-body" part="modal-body" class="md-modal__body">
                        <slot></slot>
                      </div>
                      ${this.footerTemplate()}
                    </div>
                  </div>
                </div>
              </div>
            `:l.nothing}
      `}};c([(0,d.property)({type:Boolean})],e.prototype,"show",void 0),c([(0,d.property)({type:String})],e.prototype,"headerLabel",void 0),c([(0,d.property)({type:String})],e.prototype,"headerMessage",void 0),c([(0,d.property)({type:String})],e.prototype,"htmlId",void 0),c([(0,d.property)({type:String,attribute:"aria-label"})],e.prototype,"ariaLabel",void 0),c([(0,d.property)({type:String})],e.prototype,"ariaLabelClose",void 0),c([(0,d.property)({type:String})],e.prototype,"ariaLabelCancel",void 0),c([(0,d.property)({type:String})],e.prototype,"ariaLabelSubmit",void 0),c([(0,d.property)({type:String})],e.prototype,"ariaDescription",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"showCloseButton",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"backdropClickExit",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"noExitOnEsc",void 0),c([(0,d.property)({type:String})],e.prototype,"size",void 0),c([(0,d.property)({type:String})],e.prototype,"closeBtnName",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"hideFooter",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"hideHeader",void 0),c([(0,d.property)({type:Boolean})],e.prototype,"disableInitialFocus",void 0),c([(0,d.property)({type:String})],e.prototype,"alignment",void 0),c([(0,d.state)()],e.prototype,"animating",void 0),c([(0,d.query)(".md-modal__backdrop")],e.prototype,"backDrop",void 0),e=c([(0,r.w)("md-modal")],e),t.ELEMENT=e}(y||(y={}))},1156(e,o,a){var i,s;e.exports=(i={styleMap:()=>t.styleMap},s={},a.d(s,i),s)},2927(t,o,a){var i,s;t.exports=(i={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html,nothing:()=>e.nothing},s={},a.d(s,i),s)},3496(t,e,a){var i,s;t.exports=(i={default:()=>o.default},s={},a.d(s,i),s)},3517(t,e,o){var i,s;t.exports=(i={ifDefined:()=>a.ifDefined},s={},o.d(s,i),s)},4955(t,e,o){var a,s;t.exports=(a={classMap:()=>i.classMap},s={},o.d(s,a),s)},4980(t,e,o){var a,i;t.exports=(a={action:()=>s.action,computed:()=>s.computed,makeObservable:()=>s.makeObservable,observable:()=>s.observable},i={},o.d(i,a),i)},8899(t,e,o){var a,i;t.exports=(a={property:()=>r.property,query:()=>r.query,state:()=>r.state},i={},o.d(i,a),i)},9500(t,e,o){var a,i;t.exports=(a={default:()=>n.default},i={},o.d(i,a),i)}},m={};function h(t){var e=m[t];if(void 0!==e)return e.exports;var o=m[t]={exports:{}};return p[t](o,o.exports,h),o.exports}h.m=p,l=[],h.O=(t,e,o,a)=>{if(!e){var i=1/0;for(d=0;d<l.length;d++){for(var[e,o,a]=l[d],s=!0,r=0;r<e.length;r++)(!1&a||i>=a)&&Object.keys(h.O).every(t=>h.O[t](e[r]))?e.splice(r--,1):(s=!1,a<i&&(i=a));if(s){l.splice(d--,1);var n=o();void 0!==n&&(t=n)}}return t}a=a||0;for(var d=l.length;d>0&&l[d-1][2]>a;d--)l[d]=l[d-1];l[d]=[e,o,a]},h.d=(t,e)=>{for(var o in e)h.o(e,o)&&!h.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{h as __webpack_require__};d={502:0,1745:0,4545:0,4928:0,5369:0,6060:0,6433:0,6920:0,8111:0,8442:0},h.C=t=>{var e,o,{__webpack_esm_ids__:a,__webpack_esm_modules__:i,__webpack_esm_runtime__:s}=t,r=0;for(e in i)h.o(i,e)&&(h.m[e]=i[e]);for(s&&s(h);r<a.length;r++)o=a[r],h.o(d,o)&&d[o]&&d[o][0](),d[a[r]]=0;h.O()},h.O.j=t=>0===d[t];import*as c from"../9609.js";h.C(c);import*as u from"../4084.js";h.C(u);import*as v from"../3305.js";h.C(v);import*as y from"../4739.js";h.C(y);import*as f from"../7154.js";h.C(f);import*as b from"../9773.js";h.C(b);import*as g from"../5983.js";h.C(g);import*as C from"../9488.js";h.C(C);import*as _ from"../1821.js";h.C(_);import*as w from"../2364.js";h.C(w);import*as k from"../519.js";h.C(k);import*as j from"../4781.js";h.C(j);import*as E from"../5201.js";h.C(E);import*as x from"../5584.js";h.C(x);import*as L from"../8227.js";h.C(L);import*as $ from"../4700.js";h.C($);import*as M from"../3876.js";h.C(M);import*as O from"../6005.js";h.C(O);import*as F from"../561.js";h.C(F);var B=h.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9488,1821,2364,519,4781,5201,5584,8227,4700,3876,6005,561],()=>h(329));const D=(B=h.O(B)).aF,S=B.PG,T=B.o6;export{D as Modal,S as modalAlignment,T as modalType};