import { Component, Input, ViewChild } from '@angular/core';
import { NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@ionic/angular";
import * as i3 from "@angular/common";
import * as i4 from "primeng/api";
import * as i5 from "primeng/dialog";
import * as i6 from "primeng/overlaypanel";
import * as i7 from "../../pipes/translate/dynamic-translate.pipe";
import * as i8 from "../../pipes/trust-html/trust-html.pipe";
const _c0 = ["op1"];
const _c1 = ["popup"];
function OverlayInfoComponent_ng_template_2_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 8);
    i0.ɵɵpipe(1, "dynamicTranslate");
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("innerHTML", i0.ɵɵpipeBind2(1, 1, ctx_r7.overlayText, ctx_r7.param), i0.ɵɵsanitizeHtml);
} }
function OverlayInfoComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, OverlayInfoComponent_ng_template_2_div_0_Template, 2, 4, "div", 7);
    i0.ɵɵprojection(1, 1);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", ctx_r1.overlayText);
} }
function OverlayInfoComponent_ion_button_3_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ion-button", 9);
    i0.ɵɵlistener("click", function OverlayInfoComponent_ion_button_3_Template_ion_button_click_0_listener($event) { i0.ɵɵrestoreView(_r9); i0.ɵɵnextContext(); const _r0 = i0.ɵɵreference(1); return i0.ɵɵresetView(_r0.toggle($event)); });
    i0.ɵɵelement(1, "ion-icon", 10);
    i0.ɵɵelementEnd();
} }
function OverlayInfoComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 11);
    i0.ɵɵpipe(1, "trustHtml");
    i0.ɵɵpipe(2, "dynamicTranslate");
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵproperty("innerHTML", i0.ɵɵpipeBind1(1, 1, i0.ɵɵpipeBind2(2, 3, ctx_r3.displayText, ctx_r3.param)), i0.ɵɵsanitizeHtml);
} }
function OverlayInfoComponent_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 11);
    i0.ɵɵpipe(1, "trustHtml");
    i0.ɵɵpipe(2, "dynamicTranslate");
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("innerHTML", i0.ɵɵpipeBind1(1, 1, i0.ɵɵpipeBind2(2, 3, ctx_r4.displayText, ctx_r4.param)), i0.ɵɵsanitizeHtml);
} }
function OverlayInfoComponent_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 11);
    i0.ɵɵpipe(1, "trustHtml");
    i0.ɵɵpipe(2, "dynamicTranslate");
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵproperty("innerHTML", i0.ɵɵpipeBind1(1, 1, i0.ɵɵpipeBind2(2, 3, ctx_r5.displayText, ctx_r5.param)), i0.ɵɵsanitizeHtml);
} }
function OverlayInfoComponent_div_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 11);
    i0.ɵɵpipe(1, "trustHtml");
    i0.ɵɵpipe(2, "dynamicTranslate");
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext();
    i0.ɵɵproperty("innerHTML", i0.ɵɵpipeBind1(1, 1, i0.ɵɵpipeBind2(2, 3, ctx_r6.overlayText, ctx_r6.param)), i0.ɵɵsanitizeHtml);
} }
const _c2 = ["*", "*"];
const _c3 = () => ({ "width": "279px" });
const _c4 = () => ({ width: "50vw" });
const _c5 = () => ({ "960px": "40vw", "640px": "100vw" });
export class OverlayInfoComponent {
    constructor(elementRef, formBuilder) {
        this.elementRef = elementRef;
        this.formBuilder = formBuilder;
        this.displayAsLabel = false;
        this.labelWithLink = false;
        this.labelWithPopup = false;
        this.showPopup = false;
        this.onChange = (value) => {
        };
        this.onTouch = () => {
        };
    }
    ngOnChanges(changes) {
    }
    writeValue(obj) {
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouch = fn;
    }
    setDisabledState(isDisabled) {
    }
    ngOnInit() {
        this.concentForm = this.formBuilder.group({
            'concent': [false]
        });
        this.concent.valueChanges.subscribe(val => {
            this.onChange(val);
        });
    }
    get concent() {
        return this.concentForm.controls['concent'];
    }
    ngAfterViewInit() {
        if (this.displayAsLabel) {
            if (this.elementRef.nativeElement.querySelector('a')) {
                this.elementRef.nativeElement
                    .querySelector('a')
                    .addEventListener('click', this.openOverlay.bind(this));
            }
        }
        if (this.labelWithPopup) {
            if (this.elementRef.nativeElement.querySelector('a')) {
                this.elementRef.nativeElement
                    .querySelector('a')
                    .addEventListener('click', this.openPopup.bind(this));
            }
        }
    }
    openOverlay(event) {
        if (this.op1) {
            this.op1.show(event);
        }
    }
    openPopup(event) {
        this.showPopup = true;
    }
    static { this.ɵfac = function OverlayInfoComponent_Factory(t) { return new (t || OverlayInfoComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1.UntypedFormBuilder)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: OverlayInfoComponent, selectors: [["app-overlay-info"]], viewQuery: function OverlayInfoComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 5);
            i0.ɵɵviewQuery(_c1, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.op1 = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.popup = _t.first);
        } }, inputs: { displayText: "displayText", overlayText: "overlayText", param: "param", displayAsLabel: "displayAsLabel", labelWithLink: "labelWithLink", labelWithPopup: "labelWithPopup" }, features: [i0.ɵɵProvidersFeature([{
                    provide: NG_VALUE_ACCESSOR,
                    useExisting: OverlayInfoComponent,
                    multi: true
                },
                {
                    provide: NG_VALIDATORS,
                    multi: true,
                    useExisting: OverlayInfoComponent
                }
            ]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c2, decls: 13, vars: 16, consts: [[3, "appendTo"], ["op1", ""], ["pTemplate", ""], ["fill", "outline", "size", "small", "shape", "round", "class", "small-button", "aria-label", "info button", 3, "click", 4, "ngIf"], [3, "innerHTML", 4, "ngIf"], ["appendTo", "body", "position", "top", 3, "visible", "modal", "breakpoints"], ["shape", "round", "type", "reset", "color", "success", "fill", "outline", 3, "click"], ["class", "overlay-desc", 3, "innerHTML", 4, "ngIf"], [1, "overlay-desc", 3, "innerHTML"], ["fill", "outline", "size", "small", "shape", "round", "aria-label", "info button", 1, "small-button", 3, "click"], ["slot", "icon-only", "name", "information-outline", "aria-hidden", "true", 1, "button-icon"], [3, "innerHTML"]], template: function OverlayInfoComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c2);
            i0.ɵɵelementStart(0, "p-overlayPanel", 0, 1);
            i0.ɵɵtemplate(2, OverlayInfoComponent_ng_template_2_Template, 2, 1, "ng-template", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(3, OverlayInfoComponent_ion_button_3_Template, 2, 0, "ion-button", 3)(4, OverlayInfoComponent_div_4_Template, 3, 6, "div", 4)(5, OverlayInfoComponent_div_5_Template, 3, 6, "div", 4)(6, OverlayInfoComponent_div_6_Template, 3, 6, "div", 4);
            i0.ɵɵelementStart(7, "p-dialog", 5);
            i0.ɵɵtemplate(8, OverlayInfoComponent_div_8_Template, 3, 6, "div", 4);
            i0.ɵɵprojection(9);
            i0.ɵɵelementStart(10, "p-footer")(11, "ion-button", 6);
            i0.ɵɵlistener("click", function OverlayInfoComponent_Template_ion_button_click_11_listener() { return ctx.showPopup = false; });
            i0.ɵɵtext(12, " Close ");
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵstyleMap(i0.ɵɵpureFunction0(13, _c3));
            i0.ɵɵproperty("appendTo", "body");
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", !ctx.displayAsLabel && !ctx.labelWithLink && !ctx.labelWithPopup);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.displayAsLabel);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.labelWithLink);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.labelWithPopup);
            i0.ɵɵadvance(1);
            i0.ɵɵstyleMap(i0.ɵɵpureFunction0(14, _c4));
            i0.ɵɵproperty("visible", ctx.showPopup)("modal", true)("breakpoints", i0.ɵɵpureFunction0(15, _c5));
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.overlayText);
        } }, dependencies: [i2.IonButton, i2.IonIcon, i3.NgIf, i4.Footer, i4.PrimeTemplate, i5.Dialog, i6.OverlayPanel, i7.DynamicTranslatePipe, i8.TrustHtmlPipe], styles: ["[_nghost-%COMP%]     .p-overlaypanel{width:279px!important}[_nghost-%COMP%]     .p-button.p-button-icon-only{background-color:transparent!important}[_nghost-%COMP%]     .p-button.p-button-icon-only.p-button-rounded{border-radius:50%;height:-moz-fit-content!important;height:fit-content!important}[_nghost-%COMP%]     .p-overlaypanel .p-overlaypanel-content{padding:24px 24px 12px}[_nghost-%COMP%]     a{cursor:pointer;color:var(--ion-color-primary)!important;text-decoration:none}[_nghost-%COMP%]     a:hover{text-decoration:underline;text-underline-offset:3px}[_nghost-%COMP%]     ol, [_nghost-%COMP%]     ul{list-style:none!important}[_nghost-%COMP%]     ul{list-style-type:square!important}[_nghost-%COMP%]     li{font-family:var(--app-font-light)!important}.small-button[_ngcontent-%COMP%]{--padding-start: 0px;--padding-end: 0px;--background: white;--border: none !important;margin-top:1px;--color: var(--ion-color-primary);--border-color: var(--ion-color-primary);--border-width: 2px }ion-button.small-button[_ngcontent-%COMP%]::part(native){padding:3px}.button-icon[_ngcontent-%COMP%]{font-size:18px;color:var(--ion-color-primary)}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(OverlayInfoComponent, [{
        type: Component,
        args: [{ selector: 'app-overlay-info', providers: [{
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: OverlayInfoComponent,
                        multi: true
                    },
                    {
                        provide: NG_VALIDATORS,
                        multi: true,
                        useExisting: OverlayInfoComponent
                    }
                ], template: "\r\n<p-overlayPanel #op1 [appendTo]=\"'body'\" [style]=\"{'width': '279px'}\">\r\n  <ng-template pTemplate>\r\n    <div [innerHTML]=\"overlayText | dynamicTranslate:param\" class=\"overlay-desc\" *ngIf=\"overlayText\"></div>\r\n    <ng-content></ng-content>\r\n  </ng-template>\r\n</p-overlayPanel>\r\n\r\n<ion-button fill=\"outline\" size=\"small\" shape=\"round\" class=\"small-button\" *ngIf=\"!displayAsLabel && !labelWithLink && !labelWithPopup\" aria-label=\"info button\" (click)=\"op1.toggle($event)\">\r\n  <ion-icon slot=\"icon-only\" name=\"information-outline\" class=\"button-icon\" aria-hidden=\"true\"></ion-icon>\r\n</ion-button>\r\n<div *ngIf=\"displayAsLabel\" [innerHTML]=\"displayText | dynamicTranslate:param | trustHtml\"></div>\r\n<div *ngIf=\"labelWithLink\" [innerHTML]=\"displayText | dynamicTranslate:param | trustHtml\"></div>\r\n<div *ngIf=\"labelWithPopup\" [innerHTML]=\"displayText | dynamicTranslate:param | trustHtml\"></div>\r\n\r\n<p-dialog [visible]=\"showPopup\" [modal]=\"true\" appendTo=\"body\" [breakpoints]=\"{'960px': '40vw', '640px': '100vw'}\" [style]=\"{width: '50vw'}\" position=\"top\">\r\n  <div [innerHTML]=\"overlayText | dynamicTranslate:param | trustHtml\" *ngIf=\"overlayText\"></div>\r\n  <ng-content></ng-content>\r\n  <p-footer>\r\n    <ion-button shape=\"round\" type=\"reset\" (click)=\"showPopup = false\" color=\"success\" fill=\"outline\">\r\n      Close\r\n    </ion-button>\r\n  </p-footer>\r\n</p-dialog>", styles: [":host ::ng-deep .p-overlaypanel{width:279px!important}:host ::ng-deep .p-button.p-button-icon-only{background-color:transparent!important}:host ::ng-deep .p-button.p-button-icon-only.p-button-rounded{border-radius:50%;height:-moz-fit-content!important;height:fit-content!important}:host ::ng-deep .p-overlaypanel .p-overlaypanel-content{padding:24px 24px 12px}:host ::ng-deep a{cursor:pointer;color:var(--ion-color-primary)!important;text-decoration:none}:host ::ng-deep a:hover{text-decoration:underline;text-underline-offset:3px}:host ::ng-deep ol,:host ::ng-deep ul{list-style:none!important}:host ::ng-deep ul{list-style-type:square!important}:host ::ng-deep li{font-family:var(--app-font-light)!important}.small-button{--padding-start: 0px;--padding-end: 0px;--background: white;--border: none !important;margin-top:1px;--color: var(--ion-color-primary);--border-color: var(--ion-color-primary);--border-width: 2px }ion-button.small-button::part(native){padding:3px}.button-icon{font-size:18px;color:var(--ion-color-primary)}\n"] }]
    }], () => [{ type: i0.ElementRef }, { type: i1.UntypedFormBuilder }], { op1: [{
            type: ViewChild,
            args: ['op1', { static: false }]
        }], popup: [{
            type: ViewChild,
            args: ['popup', { static: false }]
        }], displayText: [{
            type: Input
        }], overlayText: [{
            type: Input
        }], param: [{
            type: Input
        }], displayAsLabel: [{
            type: Input
        }], labelWithLink: [{
            type: Input
        }], labelWithPopup: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(OverlayInfoComponent, { className: "OverlayInfoComponent", filePath: "lib\\components\\overlay-info\\overlay-info.component.ts", lineNumber: 23 }); })();
//# sourceMappingURL=data:application/json;base64, 