import { Component, HostListener, Input } from '@angular/core';
import BaseSection from '../BaseSection';
import { CommonModule } from '@angular/common';
import { HoverDirective } from '../../directive/hover-element-directive';
import { BackgroundDirective } from '../../directive/background-directive';
import { ImageDirectiveDirective } from '../../directive/image-directive.directive';
import { OverlayDirective } from '../../directive/overlay-directive';
import { CornerDirective } from '../../directive/corner-directive';
import { HoverElementsComponent } from "../../components/hover-elements/hover-elements.component";
import { DeleteHoverElementComponent } from "../../components/delete-hover-element/delete-hover-element.component";
import { SimpoButtonComponent } from "../../elements/simpo-button/simpo-button.component";
import { BorderDirective } from '../../directive/border-directive';
import { AnimationDirective } from '../../directive/animation-directive';
import { PositionLayoutDirectiveDirective } from '../../directive/position-layout-directive.directive';
import { ObjectPositionDirective } from '../../directive/image-position.directive';
import { simpoConetenAlignmentDirective } from '../../directive/content-alignment-directive';
import { SvgDividerComponent } from '../../elements/svg-divider/svg-divider.component';
import { TextEditorComponent } from '../../elements/text-editor/text-editor.component';
import { ImageEditorDirective } from '../../directive/image-editor.directive';
import { SpacingHorizontalDirective } from '../../directive/spacing-horizontal.directive';
import { SpacingDirective } from '../../directive/spacing.directive';
import { HeightDirective } from '../../directive/height.directive';
import { SpacingAroundDirective } from '../../directive/spacing-around.directive';
import * as i0 from "@angular/core";
import * as i1 from "../../services/events.service";
import * as i2 from "@angular/common";
export class BannerGridSectionComponent extends BaseSection {
    constructor(_eventService) {
        super();
        this._eventService = _eventService;
        this.screenWidth = "";
        this.getScreenSize();
    }
    ngOnInit() {
        this.content = this.data?.content;
        this.listItems = this.data?.content.listItem.data;
        this.styles = this.data?.styles;
        if (!this.styles || !this.content)
            return;
        this.deleteSelected = this.delete;
    }
    getScreenSize() {
        this.screenWidth = window.innerWidth;
    }
    get stylesLayout() {
        //   if(this.data?.styles?.borderLessImage)
        // return undefined
        return { ...this.styles?.layout };
    }
    get canMergeNavbar() {
        return this.styles?.merge;
    }
    get isBorderlessImage() {
        return this.styles?.borderLessImage && (this.styles?.positionLayout.value == "left" || this.styles?.positionLayout.value == "right");
    }
    editSection() {
        if (window.innerWidth <= 475)
            return;
        this._eventService.toggleEditorEvent.emit(false);
        setTimeout(() => {
            this._eventService.editSection.emit({ data: this.data });
        }, 100);
    }
    getImageClass(index) {
        const itemCount = this.data?.content?.listItem?.data?.length || 0;
        if (this.screenWidth > 475 && (this.data?.styles?.positionLayout?.value === "top" || this.data?.styles?.positionLayout?.value === "bottom")) {
            if (itemCount % 3 == 0)
                return 'col-4';
            if (itemCount % 3 == 1 && index == itemCount - 1)
                return 'col-12';
            if (itemCount % 3 == 2 && (index == itemCount - 1 || index == itemCount - 2))
                return 'col-6';
            return 'col-4';
        }
        if (itemCount <= 2)
            return 'col-12';
        if (itemCount % 2 == 0)
            return 'col-6';
        if (itemCount % 2 != 0 && index == itemCount - 1)
            return 'col-12';
        return 'col-6';
    }
    get spacingLayout() {
        // if(this.data?.styles?.borderLessImage)
        //   return undefined
        return { ...this.styles?.layout?.spacing };
    }
    get alignmentLayout() {
        return this.styles?.layout?.align;
    }
    get fitLayout() {
        return this.styles?.layout?.fit;
    }
    getTextColor(bgColor) {
        if (bgColor) {
            const threshold = 130; // Adjust this threshold as needed
            const r = parseInt(bgColor.slice(1, 3), 16);
            const g = parseInt(bgColor.slice(3, 5), 16);
            const b = parseInt(bgColor.slice(5, 7), 16);
            const brightness = (r * 299 + g * 587 + b * 114) / 1000;
            return brightness > threshold ? '#000000' : '#ffffff';
        }
        return "#ffffff;";
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BannerGridSectionComponent, deps: [{ token: i1.EventsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: BannerGridSectionComponent, isStandalone: true, selector: "simpo-banner-grid-section", inputs: { data: "data", edit: "edit", delete: "delete", customClass: "customClass", index: "index", nextComponentColor: "nextComponentColor" }, host: { listeners: { "window: resize": "getScreenSize($event)" } }, usesInheritance: true, ngImport: i0, template: "<section class=\"total-container\" simpoHover (hovering)=\"showEditTabs($event)\">\r\n  <div [id]=\"data?.id\" [simpoBorder]=\"styles?.border\" [spacingAround]=\"stylesLayout\">\r\n    <div class=\"row top-parent h-100 align-justify-unset\" [id]=\"data?.id\" [simpoAnimation]=\"styles?.animation\"\r\n      [simpoPositionLayoutDirective]=\"styles?.positionLayout\"\r\n      [simpoBackground]=\"styles?.background\" [simpoHeight]=\"fitLayout\">\r\n      <div class=\"col\" [spacingHorizontal]=\"!data?.styles?.borderLessImage ? stylesLayout : undefined\"\r\n        [class.p0]=\"data?.styles?.borderLessImage\"  [simpoOverlay]=\"styles?.background\"\r\n        [simpoSpacing]=\"!data?.styles?.borderLessImage ? spacingLayout : undefined\" [id]=\"data?.id\">\r\n        <ng-container *ngTemplateOutlet=\"imageTemplate\"></ng-container>\r\n      </div>\r\n      <div class=\"col d-flex flex-column\" [spacingHorizontal]=\"stylesLayout\"  [simpoOverlay]=\"styles?.background\"\r\n        [simpoContentAlignment]=\"styles?.contentAlignment\" [simpoSpacing]=\"spacingLayout\" [id]=\"data?.id\">\r\n        <div class=\"text-parent\">\r\n          <ng-container *ngTemplateOutlet=\"textTemplate\"></ng-container>\r\n          <ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\r\n        </div>\r\n      </div>\r\n    </div>\r\n  </div>\r\n  <ng-container *ngIf=\"styles?.devider?.display\">\r\n    <simpo-svg-divider [dividerType]=\"styles?.devider?.deviderType\"\r\n      [color]=\"nextComponentColor?.color\"></simpo-svg-divider>\r\n  </ng-container>\r\n  <div [ngClass]=\"{'hover_effect': edit}\" *ngIf=\"showEditors\">\r\n    <simpo-hover-elements [data]=\"data\" [index]=\"index\" [editOptions]=\"edit\"\r\n      [isMerged]=\"styles?.merge ?? false\"></simpo-hover-elements>\r\n  </div>\r\n  <div *ngIf=\"showDelete\" [ngClass]=\"{'hover_effect': delete}\">\r\n    <simpo-delete-hover-element [data]=\"data\" [index]=\"index\"></simpo-delete-hover-element>\r\n  </div>\r\n\r\n</section>\r\n\r\n<ng-template #buttonTemplate>\r\n  <div class=\"button-display\" *ngIf=\"data?.action && data?.action?.display\" class=\"d-flex customclass w-full gap-2\"\r\n    [ngClass]=\"[\r\n      styles?.layout?.align === 'left' ? 'justify-content-md-start' : '',\r\n      styles?.layout?.align === 'center' ? 'justify-content-md-center' : '',\r\n      styles?.layout?.align === 'right' ? 'justify-content-md-end' : '',\r\n      screenWidth < 475 ? 'justify-content-center' : ''\r\n    ]\">\r\n    <ng-container *ngFor=\"let button of data?.action?.buttons\">\r\n      <app-button-element [buttonContent]=\"button.content\" [buttonStyle]=\"button.styles\" [buttonId]=\"button.id\"\r\n        [sectionId]=\"data?.id\" [color]=\"data?.styles?.background?.accentColor\" [edit]=\"edit\"\r\n        [backgroundInfo]=\"data?.styles?.background\"></app-button-element>\r\n    </ng-container>\r\n  </div>\r\n</ng-template>\r\n\r\n<ng-template #textTemplate>\r\n  <div [id]=\"data?.id\">\r\n    <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n      <div [ngClass]=\"item.label.includes('Heading') ? 'heading-large lh-2 mb-4' : 'body-large'\">\r\n        <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n      </div>\r\n    </ng-container>\r\n  </div>\r\n</ng-template>\r\n\r\n<ng-template #imageTemplate>\r\n  <div class=\"row\" [style.rowGap]=\"!data?.styles?.borderLessImage ? '15px' : '0'\">\r\n    <div *ngFor=\"let item of data?.content?.listItem?.data || []; let i = index\" [class]=\"getImageClass(i)\"\r\n      [class.p0]=\"data?.styles?.borderLessImage\"\r\n      [class.grid-img]=\"styles?.positionLayout?.value == 'left' || styles?.positionLayout?.value == 'right'\">\r\n      <img [src]=\"item?.image?.url\" [alt]=\"item?.image?.altText\" [simpoCorner]=\"styles?.corners\" [id]=\"data?.id\"\r\n        [simpoImageDirective]=\"styles?.image\" [simpoObjectPosition]=\"item?.image?.position\"\r\n        [appImageEditor]=\"edit || false\" [imageData]=\"item?.image\" [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100 h-100\">\r\n    </div>\r\n  </div>\r\n</ng-template>", styles: [".total-container{height:auto;position:relative}.float-none{float:none}.image-section{display:flex;flex-direction:column;align-items:center}.image-section .d-flex{gap:10px}.col-12{max-height:300px!important}.img{width:100%;height:auto}.align-justify-unset{align-items:unset!important;justify-content:unset!important}.borderLess-image{border-radius:0!important}.borderless-width{width:50%;height:auto}.borderLess-height{height:54vh}.img-1{width:48%;height:auto}.image-section-2{display:flex;align-items:center}.image-section-2 .d-flex{gap:10px}.image-section-2-borderless,.image-1{width:100%}.image-position{display:flex;flex-direction:row;width:100%}.image-width{width:100%;margin-right:5px}.images{width:33%}.images-top{width:33%;margin-right:15px}.image-width-top{width:100%;height:100%;margin-top:17px;margin-right:15px}.col-lg-12{width:100%!important}.total-section{min-height:calc(50vh + -0px)!important;height:auto}.image-width-2{width:50%}.images-width-2{width:100%}.image-width-3,.images-width-3{width:100%;height:450px}.button-section{gap:10px}@media only screen and (max-width: 475px){.total-section{height:auto;flex-direction:column}.py-4{padding:1rem!important}.body-large{font-size:16px;line-height:21px}.image-position{overflow-y:scroll}.images-top,.images{width:100%}.image-width,.image-width-top{height:450px;width:300px;margin-right:2px}.image-section-2{display:flex;align-items:center;overflow-y:scroll!important;width:100%}.images-width-2{width:310px;height:450px}.image-width-2{width:100%}}.mergeNavbar{margin-top:-75px;padding-top:75px}.main-container{display:flex}.button-display{display:flex;gap:10px}.p0{padding:0!important}.text-parent{display:flex;flex-direction:column;gap:15px}.grid-img{min-height:464px;max-height:50vh;object-fit:cover}.row{margin:0}@media screen and (max-width: 475px){.top-parent{flex-direction:column;margin:0}.grid-img{min-height:232px;max-height:25vh}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: HoverDirective, selector: "[simpoHover]", outputs: ["hovering"] }, { kind: "directive", type: BackgroundDirective, selector: "[simpoBackground]", inputs: ["simpoBackground", "scrollValue"] }, { kind: "directive", type: OverlayDirective, selector: "[simpoOverlay]", inputs: ["simpoOverlay"] }, { kind: "directive", type: CornerDirective, selector: "[simpoCorner]", inputs: ["simpoCorner"] }, { kind: "component", type: HoverElementsComponent, selector: "simpo-hover-elements", inputs: ["data", "index", "editOptions", "isMerged", "isEcommerce"], outputs: ["edit"] }, { kind: "component", type: DeleteHoverElementComponent, selector: "simpo-delete-hover-element", inputs: ["index", "data"], outputs: ["edit"] }, { kind: "component", type: SimpoButtonComponent, selector: "app-button-element", inputs: ["buttonContent", "buttonStyle", "buttonId", "color", "sectionId", "edit", "backgroundInfo", "disabled", "loading", "isFullWidth"] }, { kind: "directive", type: BorderDirective, selector: "[simpoBorder]", inputs: ["simpoBorder"] }, { kind: "directive", type: AnimationDirective, selector: "[simpoAnimation]", inputs: ["simpoAnimation"] }, { kind: "directive", type: PositionLayoutDirectiveDirective, selector: "[simpoPositionLayoutDirective]", inputs: ["simpoPositionLayoutDirective"] }, { kind: "directive", type: ObjectPositionDirective, selector: "[simpoObjectPosition]", inputs: ["simpoObjectPosition"] }, { kind: "directive", type: simpoConetenAlignmentDirective, selector: "[simpoContentAlignment]", inputs: ["simpoContentAlignment"] }, { kind: "component", type: TextEditorComponent, selector: "simpo-text-editor", inputs: ["value", "editable", "isRTE", "sectionId", "label", "type", "inputTextIndex", "itemIndex"], outputs: ["valueChange"] }, { kind: "directive", type: ImageEditorDirective, selector: "[appImageEditor]", inputs: ["appImageEditor", "imageData", "sectionId", "showIcon", "iconData", "itemIndex"] }, { kind: "directive", type: SpacingHorizontalDirective, selector: "[spacingHorizontal]", inputs: ["spacingHorizontal", "isHeader"] }, { kind: "directive", type: SpacingDirective, selector: "[simpoSpacing]", inputs: ["simpoSpacing"] }, { kind: "directive", type: HeightDirective, selector: "[simpoHeight]", inputs: ["simpoHeight"] }, { kind: "component", type: SvgDividerComponent, selector: "simpo-svg-divider", inputs: ["dividerType", "color"] }, { kind: "directive", type: ImageDirectiveDirective, selector: "[simpoImageDirective]", inputs: ["simpoImageDirective"] }, { kind: "directive", type: SpacingAroundDirective, selector: "[spacingAround]", inputs: ["spacingAround", "backgroundInfo"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: BannerGridSectionComponent, decorators: [{
            type: Component,
            args: [{ selector: 'simpo-banner-grid-section', standalone: true, imports: [CommonModule,
                        HoverDirective,
                        BackgroundDirective,
                        OverlayDirective,
                        CornerDirective,
                        HoverElementsComponent,
                        DeleteHoverElementComponent,
                        SimpoButtonComponent,
                        BorderDirective,
                        AnimationDirective,
                        PositionLayoutDirectiveDirective,
                        ObjectPositionDirective,
                        simpoConetenAlignmentDirective,
                        TextEditorComponent,
                        ImageEditorDirective,
                        SpacingHorizontalDirective,
                        SpacingDirective,
                        HeightDirective,
                        SvgDividerComponent,
                        ImageDirectiveDirective,
                        SpacingAroundDirective
                    ], template: "<section class=\"total-container\" simpoHover (hovering)=\"showEditTabs($event)\">\r\n  <div [id]=\"data?.id\" [simpoBorder]=\"styles?.border\" [spacingAround]=\"stylesLayout\">\r\n    <div class=\"row top-parent h-100 align-justify-unset\" [id]=\"data?.id\" [simpoAnimation]=\"styles?.animation\"\r\n      [simpoPositionLayoutDirective]=\"styles?.positionLayout\"\r\n      [simpoBackground]=\"styles?.background\" [simpoHeight]=\"fitLayout\">\r\n      <div class=\"col\" [spacingHorizontal]=\"!data?.styles?.borderLessImage ? stylesLayout : undefined\"\r\n        [class.p0]=\"data?.styles?.borderLessImage\"  [simpoOverlay]=\"styles?.background\"\r\n        [simpoSpacing]=\"!data?.styles?.borderLessImage ? spacingLayout : undefined\" [id]=\"data?.id\">\r\n        <ng-container *ngTemplateOutlet=\"imageTemplate\"></ng-container>\r\n      </div>\r\n      <div class=\"col d-flex flex-column\" [spacingHorizontal]=\"stylesLayout\"  [simpoOverlay]=\"styles?.background\"\r\n        [simpoContentAlignment]=\"styles?.contentAlignment\" [simpoSpacing]=\"spacingLayout\" [id]=\"data?.id\">\r\n        <div class=\"text-parent\">\r\n          <ng-container *ngTemplateOutlet=\"textTemplate\"></ng-container>\r\n          <ng-container *ngTemplateOutlet=\"buttonTemplate\"></ng-container>\r\n        </div>\r\n      </div>\r\n    </div>\r\n  </div>\r\n  <ng-container *ngIf=\"styles?.devider?.display\">\r\n    <simpo-svg-divider [dividerType]=\"styles?.devider?.deviderType\"\r\n      [color]=\"nextComponentColor?.color\"></simpo-svg-divider>\r\n  </ng-container>\r\n  <div [ngClass]=\"{'hover_effect': edit}\" *ngIf=\"showEditors\">\r\n    <simpo-hover-elements [data]=\"data\" [index]=\"index\" [editOptions]=\"edit\"\r\n      [isMerged]=\"styles?.merge ?? false\"></simpo-hover-elements>\r\n  </div>\r\n  <div *ngIf=\"showDelete\" [ngClass]=\"{'hover_effect': delete}\">\r\n    <simpo-delete-hover-element [data]=\"data\" [index]=\"index\"></simpo-delete-hover-element>\r\n  </div>\r\n\r\n</section>\r\n\r\n<ng-template #buttonTemplate>\r\n  <div class=\"button-display\" *ngIf=\"data?.action && data?.action?.display\" class=\"d-flex customclass w-full gap-2\"\r\n    [ngClass]=\"[\r\n      styles?.layout?.align === 'left' ? 'justify-content-md-start' : '',\r\n      styles?.layout?.align === 'center' ? 'justify-content-md-center' : '',\r\n      styles?.layout?.align === 'right' ? 'justify-content-md-end' : '',\r\n      screenWidth < 475 ? 'justify-content-center' : ''\r\n    ]\">\r\n    <ng-container *ngFor=\"let button of data?.action?.buttons\">\r\n      <app-button-element [buttonContent]=\"button.content\" [buttonStyle]=\"button.styles\" [buttonId]=\"button.id\"\r\n        [sectionId]=\"data?.id\" [color]=\"data?.styles?.background?.accentColor\" [edit]=\"edit\"\r\n        [backgroundInfo]=\"data?.styles?.background\"></app-button-element>\r\n    </ng-container>\r\n  </div>\r\n</ng-template>\r\n\r\n<ng-template #textTemplate>\r\n  <div [id]=\"data?.id\">\r\n    <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n      <div [ngClass]=\"item.label.includes('Heading') ? 'heading-large lh-2 mb-4' : 'body-large'\">\r\n        <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n      </div>\r\n    </ng-container>\r\n  </div>\r\n</ng-template>\r\n\r\n<ng-template #imageTemplate>\r\n  <div class=\"row\" [style.rowGap]=\"!data?.styles?.borderLessImage ? '15px' : '0'\">\r\n    <div *ngFor=\"let item of data?.content?.listItem?.data || []; let i = index\" [class]=\"getImageClass(i)\"\r\n      [class.p0]=\"data?.styles?.borderLessImage\"\r\n      [class.grid-img]=\"styles?.positionLayout?.value == 'left' || styles?.positionLayout?.value == 'right'\">\r\n      <img [src]=\"item?.image?.url\" [alt]=\"item?.image?.altText\" [simpoCorner]=\"styles?.corners\" [id]=\"data?.id\"\r\n        [simpoImageDirective]=\"styles?.image\" [simpoObjectPosition]=\"item?.image?.position\"\r\n        [appImageEditor]=\"edit || false\" [imageData]=\"item?.image\" [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100 h-100\">\r\n    </div>\r\n  </div>\r\n</ng-template>", styles: [".total-container{height:auto;position:relative}.float-none{float:none}.image-section{display:flex;flex-direction:column;align-items:center}.image-section .d-flex{gap:10px}.col-12{max-height:300px!important}.img{width:100%;height:auto}.align-justify-unset{align-items:unset!important;justify-content:unset!important}.borderLess-image{border-radius:0!important}.borderless-width{width:50%;height:auto}.borderLess-height{height:54vh}.img-1{width:48%;height:auto}.image-section-2{display:flex;align-items:center}.image-section-2 .d-flex{gap:10px}.image-section-2-borderless,.image-1{width:100%}.image-position{display:flex;flex-direction:row;width:100%}.image-width{width:100%;margin-right:5px}.images{width:33%}.images-top{width:33%;margin-right:15px}.image-width-top{width:100%;height:100%;margin-top:17px;margin-right:15px}.col-lg-12{width:100%!important}.total-section{min-height:calc(50vh + -0px)!important;height:auto}.image-width-2{width:50%}.images-width-2{width:100%}.image-width-3,.images-width-3{width:100%;height:450px}.button-section{gap:10px}@media only screen and (max-width: 475px){.total-section{height:auto;flex-direction:column}.py-4{padding:1rem!important}.body-large{font-size:16px;line-height:21px}.image-position{overflow-y:scroll}.images-top,.images{width:100%}.image-width,.image-width-top{height:450px;width:300px;margin-right:2px}.image-section-2{display:flex;align-items:center;overflow-y:scroll!important;width:100%}.images-width-2{width:310px;height:450px}.image-width-2{width:100%}}.mergeNavbar{margin-top:-75px;padding-top:75px}.main-container{display:flex}.button-display{display:flex;gap:10px}.p0{padding:0!important}.text-parent{display:flex;flex-direction:column;gap:15px}.grid-img{min-height:464px;max-height:50vh;object-fit:cover}.row{margin:0}@media screen and (max-width: 475px){.top-parent{flex-direction:column;margin:0}.grid-img{min-height:232px;max-height:25vh}}\n"] }]
        }], ctorParameters: () => [{ type: i1.EventsService }], propDecorators: { data: [{
                type: Input
            }], edit: [{
                type: Input
            }], delete: [{
                type: Input
            }], customClass: [{
                type: Input
            }], index: [{
                type: Input
            }], nextComponentColor: [{
                type: Input
            }], getScreenSize: [{
                type: HostListener,
                args: ["window: resize", ["$event"]]
            }] } });
//# sourceMappingURL=data:application/json;base64, 