var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component } from '@angular/core';
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { Metadata, RunView, CompositeKey } from '@memberjunction/core';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-shared";
import * as i2 from "@memberjunction/ng-shared-generic";
import * as i3 from "@angular/common";
function CommunicationTemplatesResourceComponent_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "mj-loading", 11);
    i0.ɵɵelementEnd();
} }
function CommunicationTemplatesResourceComponent_Conditional_15_For_4_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵlistener("click", function CommunicationTemplatesResourceComponent_Conditional_15_For_4_Template_div_click_0_listener() { const cat_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onCategoryFilter(cat_r4)); });
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const cat_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("active", ctx_r1.categoryFilter === cat_r4);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate2(" ", cat_r4, " (", ctx_r1.getCategoryCount(cat_r4), ") ");
} }
function CommunicationTemplatesResourceComponent_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 9)(1, "div", 12);
    i0.ɵɵlistener("click", function CommunicationTemplatesResourceComponent_Conditional_15_Template_div_click_1_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onCategoryFilter("")); });
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵrepeaterCreate(3, CommunicationTemplatesResourceComponent_Conditional_15_For_4_Template, 2, 4, "div", 13, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵclassProp("active", ctx_r1.categoryFilter === "");
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" All (", ctx_r1.allTemplates.length, ") ");
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.categories);
} }
function CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 23);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const card_r6 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", card_r6.Entity.Description, " ");
} }
function CommunicationTemplatesResourceComponent_Conditional_16_For_2_For_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 26);
    i0.ɵɵelement(1, "i");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ct_r7 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵclassMap(ctx_r1.getContentTypeIcon(ct_r7));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", ct_r7, " ");
} }
function CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 27);
    i0.ɵɵtext(1, " No content ");
    i0.ɵɵelementEnd();
} }
function CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 28);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "date");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const card_r6 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" Updated ", i0.ɵɵpipeBind2(2, 1, card_r6.LastUpdated, "mediumDate"), " ");
} }
function CommunicationTemplatesResourceComponent_Conditional_16_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵlistener("click", function CommunicationTemplatesResourceComponent_Conditional_16_For_2_Template_div_click_0_listener() { const card_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.openTemplate(card_r6.Entity)); });
    i0.ɵɵelementStart(1, "div", 17)(2, "div", 18);
    i0.ɵɵelement(3, "i", 19);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 20)(5, "div", 21);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "div", 22);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd()()();
    i0.ɵɵconditionalCreate(9, CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_9_Template, 2, 1, "div", 23);
    i0.ɵɵelementStart(10, "div", 24)(11, "div", 25);
    i0.ɵɵrepeaterCreate(12, CommunicationTemplatesResourceComponent_Conditional_16_For_2_For_13_Template, 3, 3, "span", 26, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵconditionalCreate(14, CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_14_Template, 2, 0, "span", 27);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(15, CommunicationTemplatesResourceComponent_Conditional_16_For_2_Conditional_15_Template, 3, 4, "div", 28);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const card_r6 = ctx.$implicit;
    i0.ɵɵadvance(6);
    i0.ɵɵtextInterpolate(card_r6.Entity.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(card_r6.CategoryName);
    i0.ɵɵadvance();
    i0.ɵɵconditional(card_r6.Entity.Description ? 9 : -1);
    i0.ɵɵadvance(3);
    i0.ɵɵrepeater(card_r6.ContentTypes);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(card_r6.ContentTypes.length === 0 ? 14 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(card_r6.LastUpdated ? 15 : -1);
} }
function CommunicationTemplatesResourceComponent_Conditional_16_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵelement(1, "i", 19);
    i0.ɵɵelementStart(2, "p");
    i0.ɵɵtext(3, "No templates found matching your criteria");
    i0.ɵɵelementEnd()();
} }
function CommunicationTemplatesResourceComponent_Conditional_16_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵrepeaterCreate(1, CommunicationTemplatesResourceComponent_Conditional_16_For_2_Template, 16, 5, "div", 14, i0.ɵɵrepeaterTrackByIdentity);
    i0.ɵɵconditionalCreate(3, CommunicationTemplatesResourceComponent_Conditional_16_Conditional_3_Template, 4, 0, "div", 15);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.filteredTemplates);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r1.filteredTemplates.length === 0 ? 3 : -1);
} }
let CommunicationTemplatesResourceComponent = class CommunicationTemplatesResourceComponent extends BaseResourceComponent {
    cdr;
    navService;
    allTemplates = [];
    filteredTemplates = [];
    categories = [];
    categoryFilter = '';
    isLoading = false;
    searchTerm = '';
    constructor(cdr, navService) {
        super();
        this.cdr = cdr;
        this.navService = navService;
    }
    async ngOnInit() {
        await this.loadData();
        this.NotifyLoadComplete();
    }
    ngOnDestroy() { }
    async loadData() {
        try {
            this.isLoading = true;
            this.cdr.detectChanges();
            const rv = new RunView();
            const [templatesResult, contentsResult] = await Promise.all([
                rv.RunView({
                    EntityName: 'MJ: Templates',
                    OrderBy: 'Name ASC',
                    ResultType: 'entity_object'
                }),
                rv.RunView({
                    EntityName: 'MJ: Template Contents',
                    ResultType: 'entity_object'
                })
            ]);
            if (templatesResult.Success) {
                const contents = contentsResult.Success ? contentsResult.Results : [];
                this.allTemplates = templatesResult.Results.map(t => this.buildTemplateCard(t, contents));
                this.categories = this.extractCategories(this.allTemplates);
                this.applyFilter();
            }
        }
        catch (error) {
            console.error('Error loading templates:', error);
        }
        finally {
            this.isLoading = false;
            this.cdr.detectChanges();
        }
    }
    buildTemplateCard(template, allContents) {
        const templateContents = allContents.filter(c => UUIDsEqual(c.TemplateID, template.ID));
        const contentTypes = [...new Set(templateContents.map(c => c.TypeID ? 'Content' : 'Text'))];
        const category = template.Category || 'Uncategorized';
        const lastUpdated = template.Get('__mj_UpdatedAt');
        return {
            Entity: template,
            ContentTypes: contentTypes.length > 0 ? contentTypes : [],
            LastUpdated: lastUpdated,
            CategoryName: category
        };
    }
    extractCategories(cards) {
        const cats = new Set(cards.map(c => c.CategoryName));
        return Array.from(cats).sort();
    }
    getCategoryCount(category) {
        return this.allTemplates.filter(t => t.CategoryName === category).length;
    }
    onSearch(event) {
        this.searchTerm = event.target.value.toLowerCase();
        this.applyFilter();
    }
    onCategoryFilter(category) {
        this.categoryFilter = category;
        this.applyFilter();
    }
    applyFilter() {
        let filtered = this.allTemplates;
        if (this.categoryFilter) {
            filtered = filtered.filter(t => t.CategoryName === this.categoryFilter);
        }
        if (this.searchTerm) {
            filtered = filtered.filter(t => t.Entity.Name?.toLowerCase().includes(this.searchTerm) ||
                t.Entity.Description?.toLowerCase().includes(this.searchTerm) ||
                t.CategoryName.toLowerCase().includes(this.searchTerm));
        }
        this.filteredTemplates = filtered;
        this.cdr.detectChanges();
    }
    openTemplate(template) {
        const pk = new CompositeKey();
        pk.LoadFromEntityInfoAndRecord(new Metadata().Entities.find(e => e.Name === 'MJ: Templates'), template);
        this.navService.OpenEntityRecord('MJ: Templates', pk);
    }
    addNewTemplate() {
        this.navService.OpenEntityRecord('MJ: Templates', new CompositeKey());
    }
    getContentTypeIcon(type) {
        const t = type.toLowerCase();
        if (t.includes('html'))
            return 'fa-solid fa-code';
        if (t.includes('text') || t.includes('plain'))
            return 'fa-solid fa-align-left';
        if (t.includes('sms'))
            return 'fa-solid fa-comment-sms';
        return 'fa-solid fa-file';
    }
    async GetResourceDisplayName(data) {
        return 'Templates';
    }
    async GetResourceIconClass(data) {
        return 'fa-solid fa-file-lines';
    }
    static ɵfac = function CommunicationTemplatesResourceComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CommunicationTemplatesResourceComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i1.NavigationService)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CommunicationTemplatesResourceComponent, selectors: [["mj-communication-templates-resource"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 17, vars: 3, consts: [[1, "templates-wrapper"], [1, "templates-header"], [1, "header-actions"], [1, "search-input-wrapper"], [1, "fa-solid", "fa-search"], ["type", "text", "placeholder", "Search templates...", 3, "input"], [1, "tb-btn", "primary", 3, "click"], [1, "fa-solid", "fa-plus"], [1, "loading-state"], [1, "category-filters"], [1, "templates-grid"], ["text", "Loading templates..."], [1, "filter-chip", 3, "click"], [1, "filter-chip", 3, "active"], [1, "template-card"], [1, "empty-state"], [1, "template-card", 3, "click"], [1, "template-card-header"], [1, "template-icon"], [1, "fa-solid", "fa-file-lines"], [1, "template-title-area"], [1, "template-name"], [1, "template-category"], [1, "template-description"], [1, "template-meta"], [1, "template-content-types"], [1, "content-type-chip"], [1, "content-type-chip", "empty"], [1, "template-updated"]], template: function CommunicationTemplatesResourceComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div")(3, "h2");
            i0.ɵɵtext(4, "Communication Templates");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "p");
            i0.ɵɵtext(6, "Manage reusable message templates");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(7, "div", 2)(8, "div", 3);
            i0.ɵɵelement(9, "i", 4);
            i0.ɵɵelementStart(10, "input", 5);
            i0.ɵɵlistener("input", function CommunicationTemplatesResourceComponent_Template_input_input_10_listener($event) { return ctx.onSearch($event); });
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(11, "button", 6);
            i0.ɵɵlistener("click", function CommunicationTemplatesResourceComponent_Template_button_click_11_listener() { return ctx.addNewTemplate(); });
            i0.ɵɵelement(12, "i", 7);
            i0.ɵɵtext(13, " New Template ");
            i0.ɵɵelementEnd()()();
            i0.ɵɵconditionalCreate(14, CommunicationTemplatesResourceComponent_Conditional_14_Template, 2, 0, "div", 8);
            i0.ɵɵconditionalCreate(15, CommunicationTemplatesResourceComponent_Conditional_15_Template, 5, 3, "div", 9);
            i0.ɵɵconditionalCreate(16, CommunicationTemplatesResourceComponent_Conditional_16_Template, 4, 1, "div", 10);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(14);
            i0.ɵɵconditional(ctx.isLoading ? 14 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(!ctx.isLoading ? 15 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(!ctx.isLoading ? 16 : -1);
        } }, dependencies: [i2.LoadingComponent, i3.DatePipe], styles: [".templates-wrapper[_ngcontent-%COMP%] {\n        height: 100%;\n        padding: 24px;\n        overflow-y: auto;\n        background: var(--mj-bg-surface);\n    }\n\n    \n\n    .templates-header[_ngcontent-%COMP%] {\n        display: flex;\n        justify-content: space-between;\n        align-items: flex-start;\n        margin-bottom: 20px;\n    }\n    .templates-header[_ngcontent-%COMP%]   h2[_ngcontent-%COMP%] {\n        margin: 0;\n        font-size: 18px;\n        font-weight: 800;\n        color: var(--mj-text-primary);\n    }\n    .templates-header[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n        margin: 4px 0 0;\n        font-size: 13px;\n        color: var(--mj-text-muted);\n    }\n    .header-actions[_ngcontent-%COMP%] {\n        display: flex;\n        align-items: center;\n        gap: 12px;\n    }\n    .search-input-wrapper[_ngcontent-%COMP%] {\n        display: flex;\n        align-items: center;\n        gap: 8px;\n        padding: 6px 12px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 8px;\n        background: var(--mj-bg-surface-card);\n        transition: border-color 0.15s, box-shadow 0.15s;\n        min-width: 220px;\n    }\n    .search-input-wrapper[_ngcontent-%COMP%]:focus-within {\n        border-color: var(--mj-brand-primary);\n        box-shadow: 0 0 0 2px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n    }\n    .search-input-wrapper[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { color: var(--mj-text-muted); font-size: 12px; }\n    .search-input-wrapper[_ngcontent-%COMP%]   input[_ngcontent-%COMP%] {\n        flex: 1; border: none; outline: none;\n        background: transparent; font-size: 12px;\n        font-family: inherit; color: var(--mj-text-primary);\n    }\n    .search-input-wrapper[_ngcontent-%COMP%]   input[_ngcontent-%COMP%]::placeholder { color: var(--mj-text-muted); }\n\n    .tb-btn[_ngcontent-%COMP%] {\n        display: inline-flex; align-items: center;\n        gap: 6px; padding: 8px 16px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 4px;\n        background: var(--mj-bg-surface-card);\n        color: var(--mj-text-muted);\n        font-size: 12px; font-weight: 600;\n        cursor: pointer; transition: all 0.15s ease;\n        font-family: inherit;\n    }\n    .tb-btn.primary[_ngcontent-%COMP%] {\n        background: var(--mj-brand-primary);\n        color: var(--mj-text-inverse);\n        border-color: var(--mj-brand-primary);\n    }\n    .tb-btn.primary[_ngcontent-%COMP%]:hover { filter: brightness(1.1); }\n\n    .loading-state[_ngcontent-%COMP%] {\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        padding: 80px 0;\n    }\n\n    \n\n    .category-filters[_ngcontent-%COMP%] {\n        display: flex;\n        flex-wrap: wrap;\n        gap: 8px;\n        margin-bottom: 20px;\n    }\n    .filter-chip[_ngcontent-%COMP%] {\n        display: inline-flex; align-items: center;\n        gap: 4px; padding: 5px 14px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 16px;\n        background: var(--mj-bg-surface-card);\n        font-size: 12px; font-weight: 500;\n        color: var(--mj-text-muted);\n        cursor: pointer; transition: all 0.15s;\n    }\n    .filter-chip[_ngcontent-%COMP%]:hover {\n        border-color: var(--mj-border-strong);\n        background: var(--mj-bg-surface);\n    }\n    .filter-chip.active[_ngcontent-%COMP%] {\n        border-color: var(--mj-brand-primary);\n        background: color-mix(in srgb, var(--mj-brand-primary) 15%, var(--mj-bg-surface));\n        color: var(--mj-brand-primary);\n    }\n\n    \n\n    .templates-grid[_ngcontent-%COMP%] {\n        display: grid;\n        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n        gap: 16px;\n    }\n\n    .template-card[_ngcontent-%COMP%] {\n        background: var(--mj-bg-surface-card);\n        border: 1px solid var(--mj-border-default);\n        border-radius: 12px;\n        padding: 20px;\n        cursor: pointer;\n        transition: all 0.15s ease;\n    }\n    .template-card[_ngcontent-%COMP%]:hover {\n        box-shadow: 0 2px 8px var(--mj-shadow-md);\n        border-color: var(--mj-border-strong);\n    }\n\n    .template-card-header[_ngcontent-%COMP%] {\n        display: flex;\n        align-items: center;\n        gap: 14px;\n        margin-bottom: 12px;\n    }\n    .template-icon[_ngcontent-%COMP%] {\n        width: 40px; height: 40px;\n        border-radius: 8px;\n        background: color-mix(in srgb, var(--mj-brand-primary) 15%, var(--mj-bg-surface));\n        color: var(--mj-brand-primary);\n        display: flex; align-items: center; justify-content: center;\n        font-size: 16px; flex-shrink: 0;\n    }\n    .template-title-area[_ngcontent-%COMP%] { flex: 1; min-width: 0; }\n    .template-name[_ngcontent-%COMP%] {\n        font-size: 14px; font-weight: 700;\n        color: var(--mj-text-primary);\n        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n    }\n    .template-category[_ngcontent-%COMP%] {\n        font-size: 11px;\n        color: var(--mj-text-muted);\n        margin-top: 2px;\n    }\n\n    .template-description[_ngcontent-%COMP%] {\n        font-size: 12px;\n        color: var(--mj-text-muted);\n        line-height: 1.5;\n        margin-bottom: 12px;\n        display: -webkit-box;\n        -webkit-line-clamp: 2;\n        -webkit-box-orient: vertical;\n        overflow: hidden;\n    }\n\n    .template-meta[_ngcontent-%COMP%] {\n        display: flex;\n        justify-content: space-between;\n        align-items: center;\n    }\n    .template-content-types[_ngcontent-%COMP%] {\n        display: flex;\n        flex-wrap: wrap;\n        gap: 6px;\n    }\n    .content-type-chip[_ngcontent-%COMP%] {\n        display: inline-flex; align-items: center;\n        gap: 4px; padding: 3px 8px;\n        border-radius: 10px; font-size: 10px; font-weight: 500;\n        background: var(--mj-bg-surface);\n        color: var(--mj-text-muted);\n    }\n    .content-type-chip.empty[_ngcontent-%COMP%] {\n        font-style: italic;\n    }\n    .template-updated[_ngcontent-%COMP%] {\n        font-size: 10px;\n        color: var(--mj-text-muted);\n        white-space: nowrap;\n    }\n\n    \n\n    .empty-state[_ngcontent-%COMP%] {\n        grid-column: 1 / -1;\n        display: flex; flex-direction: column;\n        align-items: center; justify-content: center;\n        padding: 64px 0; color: var(--mj-text-muted);\n    }\n    .empty-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }\n    .empty-state[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] { margin: 0; font-size: 13px; }"] });
};
CommunicationTemplatesResourceComponent = __decorate([
    RegisterClass(BaseResourceComponent, 'CommunicationTemplatesResource')
], CommunicationTemplatesResourceComponent);
export { CommunicationTemplatesResourceComponent };
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CommunicationTemplatesResourceComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-communication-templates-resource', template: `
    <div class="templates-wrapper">
      <!-- HEADER -->
      <div class="templates-header">
        <div>
          <h2>Communication Templates</h2>
          <p>Manage reusable message templates</p>
        </div>
        <div class="header-actions">
          <div class="search-input-wrapper">
            <i class="fa-solid fa-search"></i>
            <input type="text" placeholder="Search templates..." (input)="onSearch($event)">
          </div>
          <button class="tb-btn primary" (click)="addNewTemplate()">
            <i class="fa-solid fa-plus"></i> New Template
          </button>
        </div>
      </div>
    
      <!-- LOADING -->
      @if (isLoading) {
        <div class="loading-state">
          <mj-loading text="Loading templates..."></mj-loading>
        </div>
      }
    
      <!-- CATEGORY FILTERS -->
      @if (!isLoading) {
        <div class="category-filters">
          <div class="filter-chip" [class.active]="categoryFilter === ''"
            (click)="onCategoryFilter('')">
            All ({{allTemplates.length}})
          </div>
          @for (cat of categories; track cat) {
            <div class="filter-chip"
              [class.active]="categoryFilter === cat"
              (click)="onCategoryFilter(cat)">
              {{cat}} ({{getCategoryCount(cat)}})
            </div>
          }
        </div>
      }
    
      <!-- TEMPLATES GRID -->
      @if (!isLoading) {
        <div class="templates-grid">
          @for (card of filteredTemplates; track card) {
            <div class="template-card"
              (click)="openTemplate(card.Entity)">
              <div class="template-card-header">
                <div class="template-icon">
                  <i class="fa-solid fa-file-lines"></i>
                </div>
                <div class="template-title-area">
                  <div class="template-name">{{card.Entity.Name}}</div>
                  <div class="template-category">{{card.CategoryName}}</div>
                </div>
              </div>
              @if (card.Entity.Description) {
                <div class="template-description">
                  {{card.Entity.Description}}
                </div>
              }
              <div class="template-meta">
                <div class="template-content-types">
                  @for (ct of card.ContentTypes; track ct) {
                    <span class="content-type-chip">
                      <i [class]="getContentTypeIcon(ct)"></i> {{ct}}
                    </span>
                  }
                  @if (card.ContentTypes.length === 0) {
                    <span class="content-type-chip empty">
                      No content
                    </span>
                  }
                </div>
                @if (card.LastUpdated) {
                  <div class="template-updated">
                    Updated {{card.LastUpdated | date:'mediumDate'}}
                  </div>
                }
              </div>
            </div>
          }
          @if (filteredTemplates.length === 0) {
            <div class="empty-state">
              <i class="fa-solid fa-file-lines"></i>
              <p>No templates found matching your criteria</p>
            </div>
          }
        </div>
      }
    </div>
    `, styles: ["\n    .templates-wrapper {\n        height: 100%;\n        padding: 24px;\n        overflow-y: auto;\n        background: var(--mj-bg-surface);\n    }\n\n    /* HEADER */\n    .templates-header {\n        display: flex;\n        justify-content: space-between;\n        align-items: flex-start;\n        margin-bottom: 20px;\n    }\n    .templates-header h2 {\n        margin: 0;\n        font-size: 18px;\n        font-weight: 800;\n        color: var(--mj-text-primary);\n    }\n    .templates-header p {\n        margin: 4px 0 0;\n        font-size: 13px;\n        color: var(--mj-text-muted);\n    }\n    .header-actions {\n        display: flex;\n        align-items: center;\n        gap: 12px;\n    }\n    .search-input-wrapper {\n        display: flex;\n        align-items: center;\n        gap: 8px;\n        padding: 6px 12px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 8px;\n        background: var(--mj-bg-surface-card);\n        transition: border-color 0.15s, box-shadow 0.15s;\n        min-width: 220px;\n    }\n    .search-input-wrapper:focus-within {\n        border-color: var(--mj-brand-primary);\n        box-shadow: 0 0 0 2px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n    }\n    .search-input-wrapper i { color: var(--mj-text-muted); font-size: 12px; }\n    .search-input-wrapper input {\n        flex: 1; border: none; outline: none;\n        background: transparent; font-size: 12px;\n        font-family: inherit; color: var(--mj-text-primary);\n    }\n    .search-input-wrapper input::placeholder { color: var(--mj-text-muted); }\n\n    .tb-btn {\n        display: inline-flex; align-items: center;\n        gap: 6px; padding: 8px 16px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 4px;\n        background: var(--mj-bg-surface-card);\n        color: var(--mj-text-muted);\n        font-size: 12px; font-weight: 600;\n        cursor: pointer; transition: all 0.15s ease;\n        font-family: inherit;\n    }\n    .tb-btn.primary {\n        background: var(--mj-brand-primary);\n        color: var(--mj-text-inverse);\n        border-color: var(--mj-brand-primary);\n    }\n    .tb-btn.primary:hover { filter: brightness(1.1); }\n\n    .loading-state {\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        padding: 80px 0;\n    }\n\n    /* CATEGORY FILTERS */\n    .category-filters {\n        display: flex;\n        flex-wrap: wrap;\n        gap: 8px;\n        margin-bottom: 20px;\n    }\n    .filter-chip {\n        display: inline-flex; align-items: center;\n        gap: 4px; padding: 5px 14px;\n        border: 1px solid var(--mj-border-default);\n        border-radius: 16px;\n        background: var(--mj-bg-surface-card);\n        font-size: 12px; font-weight: 500;\n        color: var(--mj-text-muted);\n        cursor: pointer; transition: all 0.15s;\n    }\n    .filter-chip:hover {\n        border-color: var(--mj-border-strong);\n        background: var(--mj-bg-surface);\n    }\n    .filter-chip.active {\n        border-color: var(--mj-brand-primary);\n        background: color-mix(in srgb, var(--mj-brand-primary) 15%, var(--mj-bg-surface));\n        color: var(--mj-brand-primary);\n    }\n\n    /* GRID */\n    .templates-grid {\n        display: grid;\n        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n        gap: 16px;\n    }\n\n    .template-card {\n        background: var(--mj-bg-surface-card);\n        border: 1px solid var(--mj-border-default);\n        border-radius: 12px;\n        padding: 20px;\n        cursor: pointer;\n        transition: all 0.15s ease;\n    }\n    .template-card:hover {\n        box-shadow: 0 2px 8px var(--mj-shadow-md);\n        border-color: var(--mj-border-strong);\n    }\n\n    .template-card-header {\n        display: flex;\n        align-items: center;\n        gap: 14px;\n        margin-bottom: 12px;\n    }\n    .template-icon {\n        width: 40px; height: 40px;\n        border-radius: 8px;\n        background: color-mix(in srgb, var(--mj-brand-primary) 15%, var(--mj-bg-surface));\n        color: var(--mj-brand-primary);\n        display: flex; align-items: center; justify-content: center;\n        font-size: 16px; flex-shrink: 0;\n    }\n    .template-title-area { flex: 1; min-width: 0; }\n    .template-name {\n        font-size: 14px; font-weight: 700;\n        color: var(--mj-text-primary);\n        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n    }\n    .template-category {\n        font-size: 11px;\n        color: var(--mj-text-muted);\n        margin-top: 2px;\n    }\n\n    .template-description {\n        font-size: 12px;\n        color: var(--mj-text-muted);\n        line-height: 1.5;\n        margin-bottom: 12px;\n        display: -webkit-box;\n        -webkit-line-clamp: 2;\n        -webkit-box-orient: vertical;\n        overflow: hidden;\n    }\n\n    .template-meta {\n        display: flex;\n        justify-content: space-between;\n        align-items: center;\n    }\n    .template-content-types {\n        display: flex;\n        flex-wrap: wrap;\n        gap: 6px;\n    }\n    .content-type-chip {\n        display: inline-flex; align-items: center;\n        gap: 4px; padding: 3px 8px;\n        border-radius: 10px; font-size: 10px; font-weight: 500;\n        background: var(--mj-bg-surface);\n        color: var(--mj-text-muted);\n    }\n    .content-type-chip.empty {\n        font-style: italic;\n    }\n    .template-updated {\n        font-size: 10px;\n        color: var(--mj-text-muted);\n        white-space: nowrap;\n    }\n\n    /* EMPTY STATE */\n    .empty-state {\n        grid-column: 1 / -1;\n        display: flex; flex-direction: column;\n        align-items: center; justify-content: center;\n        padding: 64px 0; color: var(--mj-text-muted);\n    }\n    .empty-state i { font-size: 2rem; margin-bottom: 12px; opacity: 0.5; }\n    .empty-state p { margin: 0; font-size: 13px; }\n  "] }]
    }], () => [{ type: i0.ChangeDetectorRef }, { type: i1.NavigationService }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CommunicationTemplatesResourceComponent, { className: "CommunicationTemplatesResourceComponent", filePath: "src/Communication/communication-templates-resource.component.ts", lineNumber: 311 }); })();
//# sourceMappingURL=communication-templates-resource.component.js.map