"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AtomicIpxModal: ()=>AtomicIpxModal
});
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const ipx_body_cjs_namespaceObject = require("../atomic-ipx-body/ipx-body.cjs");
const ipx_body_styles_cjs_namespaceObject = require("../atomic-ipx-body/ipx-body-styles.cjs");
const boolean_converter_cjs_namespaceObject = require("../../../converters/boolean-converter.cjs");
const binding_guard_cjs_namespaceObject = require("../../../decorators/binding-guard.cjs");
const bindings_cjs_namespaceObject = require("../../../decorators/bindings.cjs");
const error_guard_cjs_namespaceObject = require("../../../decorators/error-guard.cjs");
const watch_cjs_namespaceObject = require("../../../decorators/watch.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
const bindings_mixin_cjs_namespaceObject = require("../../../mixins/bindings-mixin.cjs");
const event_utils_cjs_namespaceObject = require("../../../utils/event-utils.cjs");
const replace_breakpoint_utils_cjs_namespaceObject = require("../../../utils/replace-breakpoint-utils.cjs");
const utils_cjs_namespaceObject = require("../../../utils/utils.cjs");
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
class AtomicIpxModal extends (0, bindings_mixin_cjs_namespaceObject.InitializeBindingsMixin)(external_lit_namespaceObject.LitElement) {
    initialize() {
        if (this.isOpen) {
            this.watchToggleOpen();
            this.updateHostClasses();
        }
    }
    connectedCallback() {
        super.connectedCallback();
        document.body.addEventListener('touchmove', this.onWindowTouchMove, {
            passive: false
        });
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        document.body.removeEventListener('touchmove', this.onWindowTouchMove);
    }
    watchToggleOpen() {
        const modalOpenedClass = 'atomic-ipx-modal-opened';
        if (this.isOpen) {
            document.body.classList.add(modalOpenedClass);
            this.bindings?.interfaceElement?.classList.add(modalOpenedClass);
            return;
        }
        document.body.classList.remove(modalOpenedClass);
        this.bindings?.interfaceElement?.classList.remove(modalOpenedClass);
    }
    willUpdate() {
        this.hasFooterSlotElements = !!this.querySelector('[slot="footer"]');
    }
    firstUpdated() {
        const id = this.id || (0, utils_cjs_namespaceObject.randomID)('atomic-ipx-modal-');
        this.id = id;
        this.setAttribute('part', 'atomic-ipx-modal');
    }
    updateHostClasses() {
        this.classList.toggle('open', this.isOpen);
    }
    render() {
        this.updateBreakpoints();
        this.updateHostClasses();
        return (0, external_lit_namespaceObject.html)`
      <div part="backdrop">
        ${(0, ipx_body_cjs_namespaceObject.renderIpxBody)({
            props: {
                i18n: this.bindings.i18n,
                visibility: this.isOpen ? 'open' : 'closed',
                displayFooterSlot: this.hasFooterSlotElements,
                onAnimationEnd: this.handleAnimationEnded,
                header: (0, external_lit_namespaceObject.html)`<slot name="header"></slot>`,
                body: (0, external_lit_namespaceObject.html)`<slot name="body"></slot>`,
                footer: (0, external_lit_namespaceObject.html)`<slot name="footer"></slot>`
            }
        })}
      </div>
    `;
    }
    constructor(...args){
        super(...args), this.isOpen = false, this.hasFooterSlotElements = true, this.updateBreakpoints = (0, utils_cjs_namespaceObject.once)(()=>(0, replace_breakpoint_utils_cjs_namespaceObject.updateBreakpoints)(this)), this.onWindowTouchMove = (e)=>{
            if (this.isOpen) e.preventDefault();
        }, this.handleAnimationEnded = ()=>{
            this.dispatchEvent((0, event_utils_cjs_namespaceObject.buildCustomEvent)('animationEnded'));
        };
    }
}
AtomicIpxModal.styles = [
    ipx_body_styles_cjs_namespaceObject.ipxBodyStyles,
    (0, external_lit_namespaceObject.css)`
      @reference '../../../utils/tailwind.global.tw.css';

      atomic-focus-trap {
        @apply contents;
        height: inherit;
      }

      :host {
        width: var(--atomic-ipx-width, 31.25rem);
        height: var(--atomic-ipx-height, 43.75rem);
        max-width: calc(100vw - 3rem);
        max-height: calc(100vh - 4.25rem);
        box-shadow: rgb(0 0 0 / 50%) 0 0 0.5rem;
        inset: auto 3rem 4.25rem auto;
        position: fixed;
        z-index: 1000;
        display: none;

        [part='backdrop'] {
          @apply pointer-events-none;
          height: inherit;
        }
      }

      :host(.open) {
        display: block;

        [part='backdrop'] {
          @apply pointer-events-auto;
          height: inherit;
          max-height: calc(100vh - 4.25rem);
        }
      }
    `
];
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof AnyBindings ? Object : AnyBindings)
], AtomicIpxModal.prototype, "bindings", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicIpxModal.prototype, "error", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object,
        attribute: false
    }),
    _ts_metadata("design:type", "u" < typeof HTMLElement ? Object : HTMLElement)
], AtomicIpxModal.prototype, "source", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Object,
        attribute: false
    }),
    _ts_metadata("design:type", "u" < typeof HTMLElement ? Object : HTMLElement)
], AtomicIpxModal.prototype, "container", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        type: Boolean,
        reflect: true,
        attribute: 'is-open',
        converter: boolean_converter_cjs_namespaceObject.booleanConverter
    })
], AtomicIpxModal.prototype, "isOpen", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)()
], AtomicIpxModal.prototype, "hasFooterSlotElements", void 0);
_ts_decorate([
    (0, watch_cjs_namespaceObject.watch)('isOpen'),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicIpxModal.prototype, "watchToggleOpen", null);
_ts_decorate([
    (0, binding_guard_cjs_namespaceObject.bindingGuard)(),
    (0, error_guard_cjs_namespaceObject.errorGuard)(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicIpxModal.prototype, "render", null);
AtomicIpxModal = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-ipx-modal'),
    (0, bindings_cjs_namespaceObject.bindings)(),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicIpxModal);
exports.AtomicIpxModal = __webpack_exports__.AtomicIpxModal;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicIpxModal"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
