var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
    var _, done = false;
    for (var i = decorators.length - 1; i >= 0; i--) {
        var context = {};
        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
        if (kind === "accessor") {
            if (result === void 0) continue;
            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
            if (_ = accept(result.get)) descriptor.get = _;
            if (_ = accept(result.set)) descriptor.set = _;
            if (_ = accept(result.init)) initializers.unshift(_);
        }
        else if (_ = accept(result)) {
            if (kind === "field") initializers.unshift(_);
            else descriptor[key] = _;
        }
    }
    if (target) Object.defineProperty(target, contextIn.name, descriptor);
    done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
    var useValue = arguments.length > 2;
    for (var i = 0; i < initializers.length; i++) {
        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
    }
    return useValue ? value : void 0;
};
import * as appstate from '../../appstate.js';
import { viewHostCss } from '../shared/css.js';
import { DeesElement, customElement, html, state, css, cssManager, } from '@design.estate/dees-element';
import {} from '@design.estate/dees-catalog';
let OpsViewEmailSecurity = (() => {
    let _classDecorators = [customElement('ops-view-email-security')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _statsState_decorators;
    let _statsState_initializers = [];
    let _statsState_extraInitializers = [];
    var OpsViewEmailSecurity = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _statsState_decorators = [state()];
            __esDecorate(this, null, _statsState_decorators, { kind: "accessor", name: "statsState", static: false, private: false, access: { has: obj => "statsState" in obj, get: obj => obj.statsState, set: (obj, value) => { obj.statsState = value; } }, metadata: _metadata }, _statsState_initializers, _statsState_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            OpsViewEmailSecurity = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        #statsState_accessor_storage = __runInitializers(this, _statsState_initializers, appstate.statsStatePart.getState());
        get statsState() { return this.#statsState_accessor_storage; }
        set statsState(value) { this.#statsState_accessor_storage = value; }
        constructor() {
            super();
            __runInitializers(this, _statsState_extraInitializers);
            const sub = appstate.statsStatePart
                .select((s) => s)
                .subscribe((s) => {
                this.statsState = s;
            });
            this.rxSubscriptions.push(sub);
        }
        static styles = [
            cssManager.defaultStyles,
            viewHostCss,
            css `
      .securityContainer {
        display: flex;
        flex-direction: column;
        gap: 24px;
      }
    `,
        ];
        render() {
            const metrics = this.statsState.securityMetrics;
            if (!metrics) {
                return html `
        <div class="loadingMessage">
          <p>Loading security metrics...</p>
        </div>
      `;
            }
            const tiles = [
                {
                    id: 'malware',
                    title: 'Malware Detection',
                    value: metrics.malwareDetected,
                    type: 'number',
                    icon: 'lucide:BugOff',
                    color: metrics.malwareDetected > 0 ? '#ef4444' : '#22c55e',
                    description: 'Malware detected',
                },
                {
                    id: 'phishing',
                    title: 'Phishing Detection',
                    value: metrics.phishingDetected,
                    type: 'number',
                    icon: 'lucide:Fish',
                    color: metrics.phishingDetected > 0 ? '#ef4444' : '#22c55e',
                    description: 'Phishing attempts detected',
                },
                {
                    id: 'suspicious',
                    title: 'Suspicious Activities',
                    value: metrics.suspiciousActivities,
                    type: 'number',
                    icon: 'lucide:TriangleAlert',
                    color: metrics.suspiciousActivities > 5 ? '#ef4444' : '#f59e0b',
                    description: 'Suspicious activities detected',
                },
                {
                    id: 'spam',
                    title: 'Spam Detection',
                    value: metrics.spamDetected,
                    type: 'number',
                    icon: 'lucide:Ban',
                    color: '#f59e0b',
                    description: 'Spam emails blocked',
                },
            ];
            return html `
      <dees-heading level="3">Email Security</dees-heading>

      <div class="securityContainer">
        <dees-statsgrid
          .tiles=${tiles}
          .minTileWidth=${200}
        ></dees-statsgrid>

        <dees-settings
          .heading=${'Security Configuration'}
          .settingsFields=${[
                { key: 'spf', label: 'SPF checking', value: 'enabled' },
                { key: 'dkim', label: 'DKIM validation', value: 'enabled' },
                { key: 'dmarc', label: 'DMARC policy', value: 'enabled' },
                { key: 'spam', label: 'Spam filtering', value: 'enabled' },
            ]}
          .actions=${[{ name: 'Edit', action: () => this.showEditSecurityDialog() }]}
        ></dees-settings>
      </div>
    `;
        }
        async showEditSecurityDialog() {
            const { DeesModal } = await import('@design.estate/dees-catalog');
            DeesModal.createAndShow({
                heading: 'Edit Security Configuration',
                content: html `
        <dees-form>
          <dees-input-checkbox .key=${'enableSPF'} .label=${'SPF checking'} .value=${true}></dees-input-checkbox>
          <dees-input-checkbox .key=${'enableDKIM'} .label=${'DKIM validation'} .value=${true}></dees-input-checkbox>
          <dees-input-checkbox .key=${'enableDMARC'} .label=${'DMARC policy enforcement'} .value=${true}></dees-input-checkbox>
          <dees-input-checkbox .key=${'enableSpamFilter'} .label=${'Spam filtering'} .value=${true}></dees-input-checkbox>
        </dees-form>
        <p style="margin-top: 12px; font-size: 12px; opacity: 0.7;">
          These settings are read-only for now. Update the dcrouter configuration to change them.
        </p>
      `,
                menuOptions: [
                    { name: 'Close', action: async (modalArg) => modalArg.destroy() },
                ],
            });
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return OpsViewEmailSecurity = _classThis;
})();
export { OpsViewEmailSecurity };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3BzLXZpZXctZW1haWwtc2VjdXJpdHkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi90c193ZWIvZWxlbWVudHMvZW1haWwvb3BzLXZpZXctZW1haWwtc2VjdXJpdHkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLE9BQU8sS0FBSyxRQUFRLE1BQU0sbUJBQW1CLENBQUM7QUFDOUMsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DLE9BQU8sRUFDTCxXQUFXLEVBQ1gsYUFBYSxFQUNiLElBQUksRUFDSixLQUFLLEVBQ0wsR0FBRyxFQUNILFVBQVUsR0FFWCxNQUFNLDZCQUE2QixDQUFDO0FBQ3JDLE9BQU8sRUFBbUIsTUFBTSw2QkFBNkIsQ0FBQztJQVNqRCxvQkFBb0I7NEJBRGhDLGFBQWEsQ0FBQyx5QkFBeUIsQ0FBQzs7OztzQkFDQyxXQUFXOzs7O29DQUFuQixTQUFRLFdBQVc7Ozs7c0NBQ2xELEtBQUssRUFBRTtZQUNSLG1MQUFTLFVBQVUsNkJBQVYsVUFBVSwrRkFBNkQ7WUFGbEYsNktBdUhDOzs7O1FBckhDLGlGQUE0QyxRQUFRLENBQUMsY0FBYyxDQUFDLFFBQVEsRUFBRyxFQUFDO1FBQWhGLElBQVMsVUFBVSxnREFBNkQ7UUFBaEYsSUFBUyxVQUFVLHNEQUE2RDtRQUVoRjtZQUNFLEtBQUssRUFBRSxDQUFDOztZQUNSLE1BQU0sR0FBRyxHQUFHLFFBQVEsQ0FBQyxjQUFjO2lCQUNoQyxNQUFNLENB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