import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Directive, Input, HostListener, NgModule } from '@angular/core';
import { PopupBaseComponent } from '@ironsource/fusion-ui/components/popup/common/base';
import * as i1$1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@ironsource/fusion-ui/directives/click-outside';
import { ClickOutsideModule } from '@ironsource/fusion-ui/directives/click-outside';
import * as i3 from '@ironsource/fusion-ui/components/dynamic-components/v1';
import { DynamicComponentsModule } from '@ironsource/fusion-ui/components/dynamic-components/v1';
import { PopupLocation } from '@ironsource/fusion-ui/components/popup/common/entities';
export * from '@ironsource/fusion-ui/components/popup/common/entities';
import * as i1 from '@ironsource/fusion-ui/components/popup/common/services';
export * from '@ironsource/fusion-ui/components/popup/common/services';

function PopupComponent_fusion_dynamic_components_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "fusion-dynamic-components", 4, 5);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("element", ctx_r1.popupData == null ? null : ctx_r1.popupData.element)("component", ctx_r1.popupData == null ? null : ctx_r1.popupData.component.type)("componentData", ctx_r1.popupData == null ? null : ctx_r1.popupData.component.data);
} }
function PopupComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0);
} }
const _c0 = ["*"];
class PopupComponent extends PopupBaseComponent {
    static { this.ɵfac = /*@__PURE__*/ (() => { let ɵPopupComponent_BaseFactory; return function PopupComponent_Factory(t) { return (ɵPopupComponent_BaseFactory || (ɵPopupComponent_BaseFactory = i0.ɵɵgetInheritedFactory(PopupComponent)))(t || PopupComponent); }; })(); }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PopupComponent, selectors: [["fusion-popup"]], features: [i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c0, decls: 5, vars: 7, consts: [[1, "popupContainer", 3, "ngClass", "fusionClickOutside", "resize"], ["popupContainer", ""], [3, "element", "component", "componentData", 4, "ngIf", "ngIfElse"], ["template", ""], [3, "element", "component", "componentData"], ["dynamicContent", ""]], template: function PopupComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "div", 0, 1);
            i0.ɵɵlistener("fusionClickOutside", function PopupComponent_Template_div_fusionClickOutside_0_listener($event) { return ctx.onClickOutside($event); })("resize", function PopupComponent_Template_div_resize_0_listener() { return ctx.onResize(); }, false, i0.ɵɵresolveWindow);
            i0.ɵɵtemplate(2, PopupComponent_fusion_dynamic_components_2_Template, 2, 3, "fusion-dynamic-components", 2)(3, PopupComponent_ng_template_3_Template, 1, 0, "ng-template", null, 3, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            const _r3 = i0.ɵɵreference(4);
            i0.ɵɵstyleProp("width", ctx.popupData == null ? null : ctx.popupData.size == null ? null : ctx.popupData.size.width, "px")("height", ctx.popupData == null ? null : ctx.popupData.size == null ? null : ctx.popupData.size.height, "px");
            i0.ɵɵproperty("ngClass", ctx.popupData == null ? null : ctx.popupData.location);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", (ctx.popupData == null ? null : ctx.popupData.component == null ? null : ctx.popupData.component.type) || (ctx.popupData == null ? null : ctx.popupData.element))("ngIfElse", _r3);
        } }, dependencies: [i1$1.NgClass, i1$1.NgIf, i2.ClickOutsideDirective, i3.DynamicComponentsComponent], styles: ["[_nghost-%COMP%]   .popupContainer.element-related[_ngcontent-%COMP%]:after{margin-left:0;position:absolute;left:50%;transform:translate(-50%)}[_nghost-%COMP%]   .popupContainer[_ngcontent-%COMP%]{position:fixed;background-color:var(--background-color);z-index:3011}[_nghost-%COMP%]   .popupContainer.top-right[_ngcontent-%COMP%]{top:5px;right:5px}[_nghost-%COMP%]   .popupContainer.top-left[_ngcontent-%COMP%]{top:5px;left:5px}[_nghost-%COMP%]   .popupContainer.bottom-right[_ngcontent-%COMP%]{bottom:5px;right:5px}[_nghost-%COMP%]   .popupContainer.bottom-left[_ngcontent-%COMP%]{bottom:5px;left:5px}[_nghost-%COMP%]   .popupContainer.element-related[_ngcontent-%COMP%]{position:absolute}[_nghost-%COMP%]   .popupContainer.element-related[_ngcontent-%COMP%]:after{border:solid;border-color:transparent transparent var(--background-color) transparent;border-width:0 7px 4px;content:\"\";position:absolute;bottom:100%}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PopupComponent, [{
        type: Component,
        args: [{ selector: 'fusion-popup', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n    #popupContainer\n    class=\"popupContainer\"\n    [ngClass]=\"popupData?.location\"\n    [style.width.px]=\"popupData?.size?.width\"\n    [style.height.px]=\"popupData?.size?.height\"\n    (fusionClickOutside)=\"onClickOutside($event)\"\n    (window:resize)=\"onResize()\"\n>\n    <fusion-dynamic-components\n        #dynamicContent\n        *ngIf=\"popupData?.component?.type || popupData?.element; else template\"\n        [element]=\"popupData?.element\"\n        [component]=\"popupData?.component.type\"\n        [componentData]=\"popupData?.component.data\"\n    >\n    </fusion-dynamic-components>\n\n    <ng-template #template>\n        <ng-content></ng-content>\n    </ng-template>\n</div>\n", styles: [":host .popupContainer.element-related:after{margin-left:0;position:absolute;left:50%;transform:translate(-50%)}:host .popupContainer{position:fixed;background-color:var(--background-color);z-index:3011}:host .popupContainer.top-right{top:5px;right:5px}:host .popupContainer.top-left{top:5px;left:5px}:host .popupContainer.bottom-right{bottom:5px;right:5px}:host .popupContainer.bottom-left{bottom:5px;left:5px}:host .popupContainer.element-related{position:absolute}:host .popupContainer.element-related:after{border:solid;border-color:transparent transparent var(--background-color) transparent;border-width:0 7px 4px;content:\"\";position:absolute;bottom:100%}\n"] }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PopupComponent, { className: "PopupComponent", filePath: "popup.component.ts", lineNumber: 10 }); })();

class PopupDirective {
    constructor(elementRef, popupService) {
        this.elementRef = elementRef;
        this.popupService = popupService;
    }
    onClick() {
        if (this.fusionPopup) {
            const popupData = {
                component: this.fusionPopup.component,
                location: this.fusionPopup.location || PopupLocation.ElementRelated
            };
            Object.assign(popupData, popupData.location === PopupLocation.ElementRelated ? { hostElement: this.elementRef } : null, this.fusionPopup.size ? { size: this.fusionPopup.size } : null, this.fusionPopup.hostElementPositionOffset
                ? {
                    hostElementPositionOffset: this.fusionPopup.hostElementPositionOffset
                }
                : null);
            this.popupService.showPopUp(popupData);
        }
    }
    static { this.ɵfac = function PopupDirective_Factory(t) { return new (t || PopupDirective)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1.PopupService)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: PopupDirective, selectors: [["", "fusionPopup", ""]], hostBindings: function PopupDirective_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("click", function PopupDirective_click_HostBindingHandler() { return ctx.onClick(); });
        } }, inputs: { fusionPopup: "fusionPopup" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PopupDirective, [{
        type: Directive,
        args: [{
                selector: '[fusionPopup]'
            }]
    }], () => [{ type: i0.ElementRef }, { type: i1.PopupService }], { fusionPopup: [{
            type: Input
        }], onClick: [{
            type: HostListener,
            args: ['click']
        }] }); })();

class PopupModule {
    static { this.ɵfac = function PopupModule_Factory(t) { return new (t || PopupModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PopupModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule, ClickOutsideModule, DynamicComponentsModule] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PopupModule, [{
        type: NgModule,
        args: [{
                imports: [CommonModule, ClickOutsideModule, DynamicComponentsModule],
                declarations: [PopupComponent, PopupDirective],
                exports: [PopupComponent, PopupDirective]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PopupModule, { declarations: [PopupComponent, PopupDirective], imports: [CommonModule, ClickOutsideModule, DynamicComponentsModule], exports: [PopupComponent, PopupDirective] }); })();

/**
 * Generated bundle index. Do not edit.
 */

export { PopupComponent, PopupDirective, PopupModule };
//# sourceMappingURL=ironsource-fusion-ui-components-popup-v2.mjs.map
