/*
 * Copyright 2015-2024 Ritense BV, the Netherlands.
 *
 * Licensed under EUPL, Version 1.2 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { delay } from 'rxjs/operators';
import { v4 as uuidv4 } from 'uuid';
import { Close24 } from '@carbon/icons';
import * as i0 from "@angular/core";
import * as i1 from "../../services/modal.service";
import * as i2 from "carbon-components-angular";
import * as i3 from "@angular/common";
export class VModalComponent {
    constructor(modalService, iconService) {
        this.modalService = modalService;
        this.iconService = iconService;
        this.appearingDelayMs = 140;
        this.hideFooter = false;
        this.closeEvent = new EventEmitter();
        this.uuid = uuidv4();
        this.visible$ = this.modalService.getModalVisible(this.uuid);
        this.showBackdrop$ = this.visible$.pipe(delay(0));
        this.appearing$ = this.modalService.appearing$;
        this.disappearing$ = this.modalService.disappearing$;
        this.mouseInsideModal$ = new BehaviorSubject(false);
        this.iconService.register(Close24);
    }
    ngOnInit() {
        this.setAppearingDelayInService();
    }
    closeModal() {
        this.closeEvent.emit();
        this.modalService.closeModal();
    }
    modalMouseEnter() {
        this.mouseInsideModal$.next(true);
    }
    modalMouseLeave() {
        this.mouseInsideModal$.next(false);
    }
    setAppearingDelayInService() {
        this.modalService.setAppearingDelay(this.appearingDelayMs);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VModalComponent, deps: [{ token: i1.ModalService }, { token: i2.IconService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: VModalComponent, selector: "v-modal", inputs: { appearingDelayMs: "appearingDelayMs", maxWidthPx: "maxWidthPx", hideFooter: "hideFooter", parentId: "parentId" }, outputs: { closeEvent: "closeEvent" }, ngImport: i0, template: "<!--\n  ~ Copyright 2015-2024 Ritense BV, the Netherlands.\n  ~\n  ~ Licensed under EUPL, Version 1.2 (the \"License\");\n  ~ you may not use this file except in compliance with the License.\n  ~ You may obtain a copy of the License at\n  ~\n  ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n  ~\n  ~ Unless required by applicable law or agreed to in writing, software\n  ~ distributed under the License is distributed on an \"AS IS\" basis,\n  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~ See the License for the specific language governing permissions and\n  ~ limitations under the License.\n  -->\n\n<ng-container\n  *ngIf=\"{\n    visible: visible$ | async,\n    appearing: appearing$ | async,\n    disappearing: disappearing$ | async,\n    showBackdrop: showBackdrop$ | async,\n    mouseInsideModal: mouseInsideModal$ | async,\n  } as obs\"\n>\n  <div\n    class=\"v-modal-backdrop\"\n    [ngClass]=\"{\n      'v-modal-backdrop--visible': obs.visible || obs.disappearing,\n      'v-modal-backdrop--backdrop': obs.showBackdrop,\n      'v-modal-backdrop--hidden': !obs.visible,\n      'v-modal-backdrop--appearing': obs.appearing,\n      'v-modal-backdrop--disappearing': obs.disappearing,\n      'v-modal-backdrop--mouse-on-backdrop': !obs.mouseInsideModal,\n    }\"\n  >\n    <ng-container\n      *ngTemplateOutlet=\"modal; context: {appearing: obs.appearing, disappearing: obs.disappearing}\"\n    ></ng-container>\n  </div>\n</ng-container>\n\n<ng-template #modal let-appearing=\"appearing\" let-disappearing=\"disappearing\">\n  <div\n    class=\"v-modal\"\n    (mouseenter)=\"modalMouseEnter()\"\n    (mouseleave)=\"modalMouseLeave()\"\n    [style.max-width.px]=\"maxWidthPx\"\n  >\n    <ng-container\n      *ngTemplateOutlet=\"modalHeader; context: {appearing: appearing, disappearing: disappearing}\"\n    ></ng-container>\n    <ng-container *ngTemplateOutlet=\"modalContent\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"modalFooter\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #modalHeader let-appearing=\"appearing\" let-disappearing=\"disappearing\">\n  <div class=\"v-modal__header\">\n    <ng-content select=\"div[role=header]\"></ng-content>\n    <div class=\"v-modal__header-overflow\">\n      <div class=\"v-modal__header-overflow-gradient\"></div>\n      <div class=\"v-modal__header-overflow-bg\"></div>\n    </div>\n    <div class=\"v-modal__header-buttons\">\n      <cds-icon-button (click)=\"closeModal()\" kind=\"ghost\" size=\"sm\">\n        <svg class=\"cds--btn__icon\" cdsIcon=\"close\" size=\"24\"></svg>\n      </cds-icon-button>\n    </div>\n  </div>\n</ng-template>\n\n<ng-template #modalContent>\n  <div class=\"v-modal__content\">\n    <ng-content select=\"div[role=content]\"></ng-content>\n  </div>\n</ng-template>\n\n<ng-template #modalFooter>\n  <div class=\"v-modal__footer\" [ngClass]=\"{'v-modal__footer--hidden': hideFooter}\">\n    <ng-content select=\"div[role=footer]\"></ng-content>\n  </div>\n</ng-template>\n", styles: [".v-modal-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;z-index:var(--v-modal-z-index);background-color:var(--v-color-backdrop-transparant);-webkit-backdrop-filter:blur(0);backdrop-filter:blur(0);transition:var(--v-modal-backdrop-transition);display:none;cursor:var(--v-modal-backdrop-cursor);padding-inline-start:var(--v-modal-backdrop-padding-inline);padding-inline-end:var(--v-modal-backdrop-padding-inline);padding-block-start:var(--v-modal-backdrop-padding-block);padding-block-end:var(--v-modal-backdrop-padding-block)}.v-modal-backdrop--visible,.v-modal-backdrop--disappearing{display:flex;align-items:center;justify-content:flex-end}.v-modal{position:relative;right:-100%;background-color:var(--v-modal-background-color);height:100%;min-height:var(--v-modal-min-height);max-height:100%;width:100%;max-width:var(--v-modal-max-width);opacity:0;transition:var(--v-modal-transition);cursor:var(--v-modal-cursor);border-radius:var(--v-modal-border-radius);overflow:hidden;display:flex;flex-direction:column;justify-content:space-between;box-shadow:var(--v-modal-box-shadow)}.v-modal-backdrop--backdrop{background-color:var(--v-modal-backdrop-color);-webkit-backdrop-filter:var(--v-modal-backdrop-filter);backdrop-filter:var(--v-modal-backdrop-filter)}.v-modal-backdrop--backdrop .v-modal{right:0;opacity:1}.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:not(.v-modal-backdrop--disappearing),.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:not(.v-modal-backdrop--appearing),.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:hover{background-color:var(--v-modal-backdrop-color-hover);-webkit-backdrop-filter:var(--v-modal-backdrop-filter-hover);backdrop-filter:var(--v-modal-backdrop-filter-hover)}.v-modal-backdrop--hidden,.v-modal-backdrop--appearing{cursor:var(--v-modal-backdrop-cursor-disappearing)}.v-modal__header{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;flex-shrink:0;background-color:var(--v-modal-header-bg-color);padding-block-start:var(--v-modal-header-padding-block);padding-block-end:var(--v-modal-header-padding-block);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);border-bottom:var(--v-modal-header-border);min-height:var(--v-modal-header-min-height);box-sizing:content-box}.v-modal__header-buttons{position:absolute;right:var(--v-modal-padding-inline);top:var(--v-modal-header-padding-block)}.v-modal__header-overflow{position:absolute;right:var(--v-modal-padding-inline);top:var(--v-modal-header-padding-block);height:calc(100% - var(--v-modal-header-padding-block) - var(--v-modal-header-padding-block));display:flex;flex-direction:row}.v-modal__header-overflow-gradient{width:var(--v-modal-header-overflow-gradient-width);height:100%;background-image:var(--v-modal-header-overflow-gradient-bg-image)}.v-modal__header-overflow-bg{width:var(--v-modal-header-overflow-width);height:100%;background-color:var(--v-modal-header-bg-color)}.v-modal__footer{display:flex;flex-shrink:0;background-color:var(--v-modal-footer-bg-color);padding-block-start:var(--v-modal-footer-padding-block);padding-block-end:var(--v-modal-footer-padding-block);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);border-top:var(--v-modal-footer-border)}.v-modal__footer--hidden{display:none}.v-modal__content{height:100%;padding-block-start:var(--v-modal-content-padding-block-start);padding-block-end:var(--v-modal-content-padding-block-end);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);overflow:auto}::ng-deep .v-modal div[role=header],::ng-deep .v-modal div[role=content],::ng-deep .v-modal div[role=footer]{width:100%}\n/*!\n * Copyright 2015-2024 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n"], dependencies: [{ kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i2.IconButton, selector: "cds-icon-button, ibm-icon-button", inputs: ["buttonNgClass", "buttonAttributes", "buttonId", "kind", "size", "type", "isExpressive", "disabled", "description"], outputs: ["click", "focus", "blur", "tooltipClick"] }, { kind: "directive", type: i2.IconDirective, selector: "[cdsIcon], [ibmIcon]", inputs: ["ibmIcon", "cdsIcon", "size", "title", "ariaLabel", "ariaLabelledBy", "ariaHidden", "isFocusable"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: VModalComponent, decorators: [{
            type: Component,
            args: [{ selector: 'v-modal', template: "<!--\n  ~ Copyright 2015-2024 Ritense BV, the Netherlands.\n  ~\n  ~ Licensed under EUPL, Version 1.2 (the \"License\");\n  ~ you may not use this file except in compliance with the License.\n  ~ You may obtain a copy of the License at\n  ~\n  ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n  ~\n  ~ Unless required by applicable law or agreed to in writing, software\n  ~ distributed under the License is distributed on an \"AS IS\" basis,\n  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~ See the License for the specific language governing permissions and\n  ~ limitations under the License.\n  -->\n\n<ng-container\n  *ngIf=\"{\n    visible: visible$ | async,\n    appearing: appearing$ | async,\n    disappearing: disappearing$ | async,\n    showBackdrop: showBackdrop$ | async,\n    mouseInsideModal: mouseInsideModal$ | async,\n  } as obs\"\n>\n  <div\n    class=\"v-modal-backdrop\"\n    [ngClass]=\"{\n      'v-modal-backdrop--visible': obs.visible || obs.disappearing,\n      'v-modal-backdrop--backdrop': obs.showBackdrop,\n      'v-modal-backdrop--hidden': !obs.visible,\n      'v-modal-backdrop--appearing': obs.appearing,\n      'v-modal-backdrop--disappearing': obs.disappearing,\n      'v-modal-backdrop--mouse-on-backdrop': !obs.mouseInsideModal,\n    }\"\n  >\n    <ng-container\n      *ngTemplateOutlet=\"modal; context: {appearing: obs.appearing, disappearing: obs.disappearing}\"\n    ></ng-container>\n  </div>\n</ng-container>\n\n<ng-template #modal let-appearing=\"appearing\" let-disappearing=\"disappearing\">\n  <div\n    class=\"v-modal\"\n    (mouseenter)=\"modalMouseEnter()\"\n    (mouseleave)=\"modalMouseLeave()\"\n    [style.max-width.px]=\"maxWidthPx\"\n  >\n    <ng-container\n      *ngTemplateOutlet=\"modalHeader; context: {appearing: appearing, disappearing: disappearing}\"\n    ></ng-container>\n    <ng-container *ngTemplateOutlet=\"modalContent\"></ng-container>\n    <ng-container *ngTemplateOutlet=\"modalFooter\"></ng-container>\n  </div>\n</ng-template>\n\n<ng-template #modalHeader let-appearing=\"appearing\" let-disappearing=\"disappearing\">\n  <div class=\"v-modal__header\">\n    <ng-content select=\"div[role=header]\"></ng-content>\n    <div class=\"v-modal__header-overflow\">\n      <div class=\"v-modal__header-overflow-gradient\"></div>\n      <div class=\"v-modal__header-overflow-bg\"></div>\n    </div>\n    <div class=\"v-modal__header-buttons\">\n      <cds-icon-button (click)=\"closeModal()\" kind=\"ghost\" size=\"sm\">\n        <svg class=\"cds--btn__icon\" cdsIcon=\"close\" size=\"24\"></svg>\n      </cds-icon-button>\n    </div>\n  </div>\n</ng-template>\n\n<ng-template #modalContent>\n  <div class=\"v-modal__content\">\n    <ng-content select=\"div[role=content]\"></ng-content>\n  </div>\n</ng-template>\n\n<ng-template #modalFooter>\n  <div class=\"v-modal__footer\" [ngClass]=\"{'v-modal__footer--hidden': hideFooter}\">\n    <ng-content select=\"div[role=footer]\"></ng-content>\n  </div>\n</ng-template>\n", styles: [".v-modal-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;z-index:var(--v-modal-z-index);background-color:var(--v-color-backdrop-transparant);-webkit-backdrop-filter:blur(0);backdrop-filter:blur(0);transition:var(--v-modal-backdrop-transition);display:none;cursor:var(--v-modal-backdrop-cursor);padding-inline-start:var(--v-modal-backdrop-padding-inline);padding-inline-end:var(--v-modal-backdrop-padding-inline);padding-block-start:var(--v-modal-backdrop-padding-block);padding-block-end:var(--v-modal-backdrop-padding-block)}.v-modal-backdrop--visible,.v-modal-backdrop--disappearing{display:flex;align-items:center;justify-content:flex-end}.v-modal{position:relative;right:-100%;background-color:var(--v-modal-background-color);height:100%;min-height:var(--v-modal-min-height);max-height:100%;width:100%;max-width:var(--v-modal-max-width);opacity:0;transition:var(--v-modal-transition);cursor:var(--v-modal-cursor);border-radius:var(--v-modal-border-radius);overflow:hidden;display:flex;flex-direction:column;justify-content:space-between;box-shadow:var(--v-modal-box-shadow)}.v-modal-backdrop--backdrop{background-color:var(--v-modal-backdrop-color);-webkit-backdrop-filter:var(--v-modal-backdrop-filter);backdrop-filter:var(--v-modal-backdrop-filter)}.v-modal-backdrop--backdrop .v-modal{right:0;opacity:1}.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:not(.v-modal-backdrop--disappearing),.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:not(.v-modal-backdrop--appearing),.v-modal-backdrop--backdrop.v-modal-backdrop--mouse-on-backdrop:hover{background-color:var(--v-modal-backdrop-color-hover);-webkit-backdrop-filter:var(--v-modal-backdrop-filter-hover);backdrop-filter:var(--v-modal-backdrop-filter-hover)}.v-modal-backdrop--hidden,.v-modal-backdrop--appearing{cursor:var(--v-modal-backdrop-cursor-disappearing)}.v-modal__header{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;flex-shrink:0;background-color:var(--v-modal-header-bg-color);padding-block-start:var(--v-modal-header-padding-block);padding-block-end:var(--v-modal-header-padding-block);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);border-bottom:var(--v-modal-header-border);min-height:var(--v-modal-header-min-height);box-sizing:content-box}.v-modal__header-buttons{position:absolute;right:var(--v-modal-padding-inline);top:var(--v-modal-header-padding-block)}.v-modal__header-overflow{position:absolute;right:var(--v-modal-padding-inline);top:var(--v-modal-header-padding-block);height:calc(100% - var(--v-modal-header-padding-block) - var(--v-modal-header-padding-block));display:flex;flex-direction:row}.v-modal__header-overflow-gradient{width:var(--v-modal-header-overflow-gradient-width);height:100%;background-image:var(--v-modal-header-overflow-gradient-bg-image)}.v-modal__header-overflow-bg{width:var(--v-modal-header-overflow-width);height:100%;background-color:var(--v-modal-header-bg-color)}.v-modal__footer{display:flex;flex-shrink:0;background-color:var(--v-modal-footer-bg-color);padding-block-start:var(--v-modal-footer-padding-block);padding-block-end:var(--v-modal-footer-padding-block);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);border-top:var(--v-modal-footer-border)}.v-modal__footer--hidden{display:none}.v-modal__content{height:100%;padding-block-start:var(--v-modal-content-padding-block-start);padding-block-end:var(--v-modal-content-padding-block-end);padding-inline-start:var(--v-modal-padding-inline);padding-inline-end:var(--v-modal-padding-inline);overflow:auto}::ng-deep .v-modal div[role=header],::ng-deep .v-modal div[role=content],::ng-deep .v-modal div[role=footer]{width:100%}\n/*!\n * Copyright 2015-2024 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n"] }]
        }], ctorParameters: () => [{ type: i1.ModalService }, { type: i2.IconService }], propDecorators: { appearingDelayMs: [{
                type: Input
            }], maxWidthPx: [{
                type: Input
            }], hideFooter: [{
                type: Input
            }], parentId: [{
                type: Input
            }], closeEvent: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 