import { Component, Input, ViewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { AnimationDirective } from '../../../directive/animation-directive';
import { BackgroundDirective } from '../../../directive/background-directive';
import { BorderDirective } from '../../../directive/border-directive';
import { CornerDirective } from '../../../directive/corner-directive';
import { HoverDirective } from '../../../directive/hover-element-directive';
import { OverlayDirective } from '../../../directive/overlay-directive';
import { ContentFitDirective } from '../../../directive/content-fit-directive';
import { SimpoComponentModule } from '../../../components/index';
import BaseSection from '../../../sections/BaseSection';
import { SpacingHorizontalDirective } from '../../../directive/spacing-horizontal.directive';
import { SimpoContainerAligment } from '../../../directive/container-alignment.directive';
import { moveItemInArray } from '@angular/cdk/drag-drop';
import { SvgDividerComponent } from '../../../elements/svg-divider/svg-divider.component';
import { TextEditorComponent } from '../../../elements/text-editor/text-editor.component';
import { SpacingAroundDirective } from '../../../directive/spacing-around.directive';
import { CategoriesWithImageBackgroundColumnsComponent } from "../categories-with-image-background-columns/categories-with-image-background-columns.component";
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "../../../services/rest.service";
import * as i3 from ".././../../services/events.service";
import * as i4 from "@angular/common";
import * as i5 from "../../../components/hover-elements/hover-elements.component";
import * as i6 from "../../../components/delete-hover-element/delete-hover-element.component";
import * as i7 from "ngx-skeleton-loader";
export class FeaturedCollectionComponent extends BaseSection {
    constructor(router, restService, _eventService) {
        super();
        this.router = router;
        this.restService = restService;
        this._eventService = _eventService;
        this.isLoading = false;
    }
    ngOnInit() {
        this.content = this.data?.content;
        this.styles = this.data?.styles;
        this.getCollectionsIds();
        this._eventService.showLoadingScreen.subscribe((response) => {
            this.isLoading = response;
        });
        // this._eventService.wrapDirection.subscribe((response)=> {
        //   if (response === this.data?.id && this.styles)
        //     this.styles.direction = response as "ROW" | "COLUMN";
        // })
        this._eventService.collectionsListEvent.subscribe((response) => {
            this.getCollectionsIds();
        });
    }
    getSliceParameters() {
        return [0, (this.styles?.maximumProduct || 0)];
    }
    getCollectionsIds() {
        if (!this.content?.collectionIds)
            return;
        this.restService.getCollectionByIds(this.content?.collectionIds).subscribe((response) => {
            this.responseData = response.filter((category) => category.featuredCollection || true).map((collection) => {
                return {
                    ...collection,
                    categoryName: collection.collectionName,
                    categoryId: collection.collectionId
                };
            });
            this.content?.collectionIds?.forEach((id, collectionIndex) => {
                let index = -1;
                this.responseData?.forEach((data, idx) => {
                    if (data.collectionId == id)
                        index = idx;
                });
                this.dropCollection(index, collectionIndex);
            });
        });
    }
    dropCollection(startIdx, endIdx) {
        if (this.responseData)
            moveItemInArray(this.responseData, startIdx, endIdx);
    }
    redirectToListPage(collection) {
        collection = collection.collectionName;
        this.router.navigate(['/list'], { queryParams: { collections: collection } });
    }
    get stylesLayout() {
        return { ...this.styles?.layout };
    }
    get getDirection() {
        return this.styles?.direction;
    }
    get isMobile() {
        return window.innerWidth <= 475;
    }
    editSection() {
        this._eventService.toggleEditorEvent.emit(false);
        setTimeout(() => {
            this._eventService.editSection.emit({ data: this.data });
        }, 100);
    }
    getJustifyContent() {
        const el = this.categoryParent?.nativeElement;
        if (!el)
            return '';
        const isOverflowing = el.scrollWidth > el.clientWidth;
        if (isOverflowing) {
            return 'flex-start';
        }
        return this.styles?.layout?.align || '';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FeaturedCollectionComponent, deps: [{ token: i1.Router }, { token: i2.RestService }, { token: i3.EventsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: FeaturedCollectionComponent, isStandalone: true, selector: "simpo-featured-collection", inputs: { data: "data", responseData: "responseData", index: "index", edit: "edit", delete: "delete", customClass: "customClass", nextComponentColor: "nextComponentColor" }, viewQueries: [{ propertyName: "categoryParent", first: true, predicate: ["categoryParent1"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"!isLoading\">\r\n  <section class=\"container-fluid total-container p-0\" [id]=\"data?.id\" simpoHover (hovering)=\"showEditTabs($event)\"\r\n    [attr.style]=\"customClass\">\r\n    <div [spacingAround]=\"stylesLayout\" [id]=\"data?.id\" [simpoBorder]=\"styles?.border\" class=\"border-radius-unset\">\r\n      <div [id]=\"data?.id\" #mainContainer [simpoAnimation]=\"styles?.animation\" [simpoBackground]=\"styles?.background\"\r\n        [simpoCorner]=\"styles?.corners\" class=\"d-flex w-100\">\r\n        <div class=\"d-flex flex-column w-100\" [simpoOverlay]=\"styles?.background\" [simpoCorner]=\"styles?.corners\"\r\n          [id]=\"data?.id\" [simpoLayout]=\"styles?.layout\" [spacingHorizontal]=\"stylesLayout\"\r\n          [simpoAnimation]=\"styles?.animation\">\r\n          <div *ngFor=\"let item of content?.inputText\" class=\"text-container\">\r\n            <!-- <div  class = \"content-side\"[innerHTML]=\"item.value | sanitizeHtml\" [ngClass]=\"item.label === 'Heading' ? 'heading-large lh-2 mb-3' : 'body-large'\"> -->\r\n            <ng-container *ngIf=\"edit || item.value\">\r\n              <div class=\"pt-3 w-100\">\r\n                <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n              </div>\r\n            </ng-container>\r\n            <!-- </div> -->\r\n          </div>\r\n          <ng-container *ngIf=\"styles?.componentStyle === 'Style1';else categoryStyle2\">\r\n            <div class=\"category-parent\" [ngClass]=\"{'flex-wrap': getDirection == 'COLUMN'}\"\r\n              [simpoContainerAlignment]=\"styles?.layout\" [id]=\"data?.id\"\r\n              [style.justifyContent]=\"!isMobile ? getJustifyContent() : ''\" #categoryParent1>\r\n              <div\r\n                *ngFor=\"let data of responseData | slice:getSliceParameters()[0]:getSliceParameters()[1]; let idx = index\"\r\n                (click)=\"redirectToListPage(data)\" class=\"d-flex flex-column align-items-center w-fit-content\"\r\n                [ngClass]=\"{ 'w-48 d-flex flex-column align-items-center' : isMobile}\">\r\n                <img [style.borderRadius.px]=\"(styles?.border?.radius ?? 1) / (isMobile ? 2 : 1)\"\r\n                  [style.height.px]=\"(styles?.containerHeight ?? 1) / (isMobile ? 2 : 1)\"\r\n                  [style.width.px]=\"(styles?.containerWidth ?? 1) / (isMobile ? 2 : 1)\" loading=\"lazy\"\r\n                  onerror=\"this.src='https://i.postimg.cc/hPS2JpV0/no-image-available.jpg'\"\r\n                  [src]=\"data.imgUrl?.[0] ?? 'https://i.postimg.cc/hPS2JpV0/no-image-available.jpg'\" alt=\"\"\r\n                  class=\"category-image\" [ngClass]=\"{'category-new-image' : isMobile && getDirection == 'COLUMN'}\">\r\n                <div *ngIf=\"content?.display?.showHeading\"\r\n                  [style.width.px]=\"(styles?.containerWidth ?? 1) / (isMobile ? 2 : 1)\">{{data.categoryName}}</div>\r\n                <!-- class=\"category-name body-large\"  -->\r\n              </div>\r\n            </div>\r\n          </ng-container>\r\n          <ng-template #categoryStyle2>\r\n            <div class=\"w-100\">\r\n              <simpo-categories-with-image-background-columns [responseData]=\"responseData\" [styles]=\"styles\"\r\n                [content]=\"content\"></simpo-categories-with-image-background-columns>\r\n            </div>\r\n          </ng-template>\r\n        </div>\r\n      </div>\r\n    </div>\r\n\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\"></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</ng-container>\r\n\r\n<ngx-skeleton-loader *ngIf=\"isLoading\" count=\"1\" appearance=\"circle\" [theme]=\"{\r\n  width: '100%',\r\n  height: '40vh',\r\n  'border-radius': '10px',\r\n  'position': 'relative',\r\n  'right': '5px'\r\n}\">\r\n</ngx-skeleton-loader>", styles: [".mt-15{margin-top:15px}*{font-family:var(--website-font-family)}mat-icon{font-family:Material Icons!important}.text-container{min-width:100px}.w-fit-content{width:fit-content!important}.total-container{height:fit-content!important;position:relative;display:block!important}.hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.category-parent{padding:25px 0% 2%;display:flex;width:100%;max-width:100%;gap:25px;overflow-x:scroll;font-size:16px!important;cursor:pointer}.hovering-effect:hover{font-size:22px!important;transition:.3s ease-in-out}.category-image{display:flex;flex-wrap:wrap;margin-bottom:15px;transition-duration:.3s;-webkit-transform:scale(1);transform:scale(1);-webkit-transition:.3s ease-in-out;transition:.3s ease-in-out}.category-image:hover{-webkit-transform:scale(1.1);transform:scale(1.1)}.category-parent::-webkit-scrollbar{display:none}.span{width:141px;height:15px}.category-name{color:#222;font-size:16px;line-height:normal;font-weight:600}.border-radius-unset{border-radius:unset!important}@media screen and (max-width : 475px){.main-container{padding-left:10px;padding-right:10px}.total-container{height:fit-content!important}.w-48{width:48%!important}.category-new-image{height:150px!important;width:100%!important}.header{gap:7px}.category-parent{gap:8px;margin-top:15px;padding-left:0!important;padding-right:0!important;padding-top:0!important}.category-parent::-webkit-scrollbar{display:flex!important;height:3px}.span{width:70.5px;height:7.5px}.category-name{font-size:12px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.SlicePipe, name: "slice" }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: SimpoComponentModule }, { kind: "component", type: i5.HoverElementsComponent, selector: "simpo-hover-elements", inputs: ["data", "index", "editOptions", "isMerged", "isEcommerce"], outputs: ["edit"] }, { kind: "component", type: i6.DeleteHoverElementComponent, selector: "simpo-delete-hover-element", inputs: ["index", "data"], outputs: ["edit"] }, { kind: "component", type: i7.NgxSkeletonLoaderComponent, selector: "ngx-skeleton-loader", inputs: ["count", "loadingText", "appearance", "animation", "ariaLabel", "theme"] }, { kind: "directive", type: 
                //directive
                AnimationDirective, selector: "[simpoAnimation]", inputs: ["simpoAnimation"] }, { kind: "directive", type: ContentFitDirective, selector: "[simpoLayout]", inputs: ["simpoLayout"] }, { kind: "directive", type: BackgroundDirective, selector: "[simpoBackground]", inputs: ["simpoBackground", "scrollValue"] }, { kind: "directive", type: BorderDirective, selector: "[simpoBorder]", inputs: ["simpoBorder"] }, { kind: "directive", type: SimpoContainerAligment, selector: "[simpoContainerAlignment]", inputs: ["simpoContainerAlignment"] }, { kind: "directive", type: SpacingHorizontalDirective, selector: "[spacingHorizontal]", inputs: ["spacingHorizontal", "isHeader"] }, { kind: "directive", type: CornerDirective, selector: "[simpoCorner]", inputs: ["simpoCorner"] }, { kind: "directive", type: HoverDirective, selector: "[simpoHover]", outputs: ["hovering"] }, { kind: "directive", type: OverlayDirective, selector: "[simpoOverlay]", inputs: ["simpoOverlay"] }, { kind: "component", type: SvgDividerComponent, selector: "simpo-svg-divider", inputs: ["dividerType", "color"] }, { kind: "component", type: TextEditorComponent, selector: "simpo-text-editor", inputs: ["value", "editable", "isRTE", "sectionId", "label", "type", "inputTextIndex", "itemIndex"], outputs: ["valueChange"] }, { kind: "directive", type: SpacingAroundDirective, selector: "[spacingAround]", inputs: ["spacingAround", "backgroundInfo"] }, { kind: "component", type: CategoriesWithImageBackgroundColumnsComponent, selector: "simpo-categories-with-image-background-columns", inputs: ["responseData", "styles", "content"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FeaturedCollectionComponent, decorators: [{
            type: Component,
            args: [{ selector: 'simpo-featured-collection', standalone: true, imports: [
                        CommonModule,
                        FormsModule,
                        SimpoComponentModule,
                        //directive
                        AnimationDirective,
                        ContentFitDirective,
                        BackgroundDirective,
                        BorderDirective,
                        SimpoContainerAligment,
                        SpacingHorizontalDirective,
                        CornerDirective,
                        HoverDirective,
                        OverlayDirective,
                        SvgDividerComponent,
                        TextEditorComponent,
                        SpacingAroundDirective,
                        CategoriesWithImageBackgroundColumnsComponent
                    ], template: "<ng-container *ngIf=\"!isLoading\">\r\n  <section class=\"container-fluid total-container p-0\" [id]=\"data?.id\" simpoHover (hovering)=\"showEditTabs($event)\"\r\n    [attr.style]=\"customClass\">\r\n    <div [spacingAround]=\"stylesLayout\" [id]=\"data?.id\" [simpoBorder]=\"styles?.border\" class=\"border-radius-unset\">\r\n      <div [id]=\"data?.id\" #mainContainer [simpoAnimation]=\"styles?.animation\" [simpoBackground]=\"styles?.background\"\r\n        [simpoCorner]=\"styles?.corners\" class=\"d-flex w-100\">\r\n        <div class=\"d-flex flex-column w-100\" [simpoOverlay]=\"styles?.background\" [simpoCorner]=\"styles?.corners\"\r\n          [id]=\"data?.id\" [simpoLayout]=\"styles?.layout\" [spacingHorizontal]=\"stylesLayout\"\r\n          [simpoAnimation]=\"styles?.animation\">\r\n          <div *ngFor=\"let item of content?.inputText\" class=\"text-container\">\r\n            <!-- <div  class = \"content-side\"[innerHTML]=\"item.value | sanitizeHtml\" [ngClass]=\"item.label === 'Heading' ? 'heading-large lh-2 mb-3' : 'body-large'\"> -->\r\n            <ng-container *ngIf=\"edit || item.value\">\r\n              <div class=\"pt-3 w-100\">\r\n                <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n              </div>\r\n            </ng-container>\r\n            <!-- </div> -->\r\n          </div>\r\n          <ng-container *ngIf=\"styles?.componentStyle === 'Style1';else categoryStyle2\">\r\n            <div class=\"category-parent\" [ngClass]=\"{'flex-wrap': getDirection == 'COLUMN'}\"\r\n              [simpoContainerAlignment]=\"styles?.layout\" [id]=\"data?.id\"\r\n              [style.justifyContent]=\"!isMobile ? getJustifyContent() : ''\" #categoryParent1>\r\n              <div\r\n                *ngFor=\"let data of responseData | slice:getSliceParameters()[0]:getSliceParameters()[1]; let idx = index\"\r\n                (click)=\"redirectToListPage(data)\" class=\"d-flex flex-column align-items-center w-fit-content\"\r\n                [ngClass]=\"{ 'w-48 d-flex flex-column align-items-center' : isMobile}\">\r\n                <img [style.borderRadius.px]=\"(styles?.border?.radius ?? 1) / (isMobile ? 2 : 1)\"\r\n                  [style.height.px]=\"(styles?.containerHeight ?? 1) / (isMobile ? 2 : 1)\"\r\n                  [style.width.px]=\"(styles?.containerWidth ?? 1) / (isMobile ? 2 : 1)\" loading=\"lazy\"\r\n                  onerror=\"this.src='https://i.postimg.cc/hPS2JpV0/no-image-available.jpg'\"\r\n                  [src]=\"data.imgUrl?.[0] ?? 'https://i.postimg.cc/hPS2JpV0/no-image-available.jpg'\" alt=\"\"\r\n                  class=\"category-image\" [ngClass]=\"{'category-new-image' : isMobile && getDirection == 'COLUMN'}\">\r\n                <div *ngIf=\"content?.display?.showHeading\"\r\n                  [style.width.px]=\"(styles?.containerWidth ?? 1) / (isMobile ? 2 : 1)\">{{data.categoryName}}</div>\r\n                <!-- class=\"category-name body-large\"  -->\r\n              </div>\r\n            </div>\r\n          </ng-container>\r\n          <ng-template #categoryStyle2>\r\n            <div class=\"w-100\">\r\n              <simpo-categories-with-image-background-columns [responseData]=\"responseData\" [styles]=\"styles\"\r\n                [content]=\"content\"></simpo-categories-with-image-background-columns>\r\n            </div>\r\n          </ng-template>\r\n        </div>\r\n      </div>\r\n    </div>\r\n\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\"></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</ng-container>\r\n\r\n<ngx-skeleton-loader *ngIf=\"isLoading\" count=\"1\" appearance=\"circle\" [theme]=\"{\r\n  width: '100%',\r\n  height: '40vh',\r\n  'border-radius': '10px',\r\n  'position': 'relative',\r\n  'right': '5px'\r\n}\">\r\n</ngx-skeleton-loader>", styles: [".mt-15{margin-top:15px}*{font-family:var(--website-font-family)}mat-icon{font-family:Material Icons!important}.text-container{min-width:100px}.w-fit-content{width:fit-content!important}.total-container{height:fit-content!important;position:relative;display:block!important}.hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.category-parent{padding:25px 0% 2%;display:flex;width:100%;max-width:100%;gap:25px;overflow-x:scroll;font-size:16px!important;cursor:pointer}.hovering-effect:hover{font-size:22px!important;transition:.3s ease-in-out}.category-image{display:flex;flex-wrap:wrap;margin-bottom:15px;transition-duration:.3s;-webkit-transform:scale(1);transform:scale(1);-webkit-transition:.3s ease-in-out;transition:.3s ease-in-out}.category-image:hover{-webkit-transform:scale(1.1);transform:scale(1.1)}.category-parent::-webkit-scrollbar{display:none}.span{width:141px;height:15px}.category-name{color:#222;font-size:16px;line-height:normal;font-weight:600}.border-radius-unset{border-radius:unset!important}@media screen and (max-width : 475px){.main-container{padding-left:10px;padding-right:10px}.total-container{height:fit-content!important}.w-48{width:48%!important}.category-new-image{height:150px!important;width:100%!important}.header{gap:7px}.category-parent{gap:8px;margin-top:15px;padding-left:0!important;padding-right:0!important;padding-top:0!important}.category-parent::-webkit-scrollbar{display:flex!important;height:3px}.span{width:70.5px;height:7.5px}.category-name{font-size:12px}}\n"] }]
        }], ctorParameters: () => [{ type: i1.Router }, { type: i2.RestService }, { type: i3.EventsService }], propDecorators: { categoryParent: [{
                type: ViewChild,
                args: ['categoryParent1', { static: false }]
            }], data: [{
                type: Input
            }], responseData: [{
                type: Input
            }], index: [{
                type: Input
            }], edit: [{
                type: Input
            }], delete: [{
                type: Input
            }], customClass: [{
                type: Input
            }], nextComponentColor: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 