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 { DeesElement, customElement, html, css, cssManager, state, } from '@design.estate/dees-element';
import './index.js';
let SzDemoViewRoutes = (() => {
    let _classDecorators = [customElement('sz-demo-view-routes')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _currentTab_decorators;
    let _currentTab_initializers = [];
    let _currentTab_extraInitializers = [];
    var SzDemoViewRoutes = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _currentTab_decorators = [state()];
            __esDecorate(this, null, _currentTab_decorators, { kind: "accessor", name: "currentTab", static: false, private: false, access: { has: obj => "currentTab" in obj, get: obj => obj.currentTab, set: (obj, value) => { obj.currentTab = value; } }, metadata: _metadata }, _currentTab_initializers, _currentTab_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            SzDemoViewRoutes = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        appui = null;
        #currentTab_accessor_storage = __runInitializers(this, _currentTab_initializers, 'all');
        get currentTab() { return this.#currentTab_accessor_storage; }
        set currentTab(value) { this.#currentTab_accessor_storage = value; }
        demoRoutes = (__runInitializers(this, _currentTab_extraInitializers), [
            // 1. HTTPS with TLS termination + auto cert
            {
                id: 'route-1',
                name: 'Web Frontend',
                description: 'Main website with TLS termination and automatic certificates',
                enabled: true,
                priority: 10,
                tags: ['web', 'https', 'production'],
                match: {
                    ports: 443,
                    domains: ['serve.zone', 'www.serve.zone'],
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.0.10', port: 3000 }],
                    tls: { mode: 'terminate', certificate: 'auto' },
                },
            },
            // 2. HTTP to HTTPS redirect
            {
                id: 'route-2',
                name: 'HTTP Redirect',
                description: 'Redirects all HTTP traffic to HTTPS',
                enabled: true,
                priority: 100,
                tags: ['web', 'http', 'redirect'],
                match: {
                    ports: 80,
                    domains: ['serve.zone', 'www.serve.zone'],
                    protocol: 'http',
                },
                action: {
                    type: 'socket-handler',
                },
            },
            // 3. Email SMTP route
            {
                id: 'route-3',
                name: 'SMTP Inbound',
                description: 'Inbound email relay for serve.zone domain',
                enabled: true,
                tags: ['email', 'smtp', 'production'],
                match: {
                    ports: 25,
                    domains: 'mail.serve.zone',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.1.5', port: 25 }],
                    tls: { mode: 'terminate', certificate: 'auto' },
                },
            },
            // 4. API gateway with path matching, rate limiting, CORS
            {
                id: 'route-4',
                name: 'API Gateway',
                description: 'API gateway with rate limiting, CORS headers, and load balancing',
                enabled: true,
                priority: 20,
                tags: ['web', 'api', 'https', 'production'],
                match: {
                    ports: 443,
                    domains: 'api.serve.zone',
                    path: '/v2/*',
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [
                        { host: ['10.0.0.20', '10.0.0.21', '10.0.0.22'], port: 8080 },
                    ],
                    tls: { mode: 'terminate', certificate: 'auto' },
                    loadBalancing: { algorithm: 'round-robin' },
                },
                security: {
                    rateLimit: { enabled: true, maxRequests: 200, window: 60 },
                    maxConnections: 5000,
                },
                headers: {
                    response: {
                        'Access-Control-Allow-Origin': '*',
                        'X-Request-Id': '{{requestId}}',
                    },
                },
            },
            // 5. WebSocket route
            {
                id: 'route-5',
                name: 'WebSocket Realtime',
                description: 'Real-time WebSocket connections for live updates',
                enabled: true,
                tags: ['web', 'https', 'websocket'],
                match: {
                    ports: 443,
                    domains: 'ws.serve.zone',
                    path: '/ws/*',
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.0.30', port: 9090 }],
                    tls: { mode: 'terminate', certificate: 'auto' },
                    websocket: { enabled: true },
                },
            },
            // 6. Wildcard domain route
            {
                id: 'route-6',
                name: 'Tenant Wildcard',
                description: 'Multi-tenant wildcard routing for customer subdomains',
                enabled: true,
                priority: 50,
                tags: ['web', 'https', 'multi-tenant'],
                match: {
                    ports: 443,
                    domains: '*.customers.serve.zone',
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.0.40', port: 8080 }],
                    tls: { mode: 'terminate', certificate: 'auto' },
                },
                security: {
                    ipAllowList: ['10.0.0.0/8', '172.16.0.0/12'],
                },
            },
            // 7. Load-balanced route with health check
            {
                id: 'route-7',
                name: 'Microservices LB',
                description: 'Load-balanced microservices backend with IP-hash affinity',
                enabled: true,
                tags: ['web', 'https', 'production'],
                match: {
                    ports: [443, 8443],
                    domains: 'services.serve.zone',
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [
                        { host: ['10.0.2.1', '10.0.2.2', '10.0.2.3', '10.0.2.4'], port: 3000 },
                    ],
                    tls: { mode: 'terminate-and-reencrypt', certificate: 'auto' },
                    loadBalancing: { algorithm: 'ip-hash' },
                },
            },
            // 8. DNS-over-HTTPS route
            {
                id: 'route-8',
                name: 'DNS over HTTPS',
                description: 'DNS-over-HTTPS resolver endpoint',
                enabled: true,
                tags: ['dns', 'https'],
                match: {
                    ports: 443,
                    domains: 'dns.serve.zone',
                    path: '/dns-query',
                    protocol: 'http',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.3.1', port: 8053 }],
                    tls: { mode: 'terminate', certificate: 'auto' },
                },
            },
            // 9. NFTables high-performance route
            {
                id: 'route-9',
                name: 'High-Perf TCP Proxy',
                description: 'NFTables-accelerated TCP proxy for game servers',
                enabled: true,
                tags: ['tcp', 'nftables', 'production'],
                match: {
                    ports: [{ from: 27000, to: 27050 }],
                    protocol: 'tcp',
                },
                action: {
                    type: 'forward',
                    targets: [{ host: '10.0.4.1', port: 'preserve' }],
                    forwardingEngine: 'nftables',
                },
            },
            // 10. Disabled maintenance route
            {
                id: 'route-10',
                name: 'Legacy Admin Panel',
                description: 'Deprecated admin panel — disabled for maintenance',
                enabled: false,
                tags: ['web', 'https', 'deprecated'],
                match: {
                    ports: 443,
                    domains: 'admin-old.serve.zone',
                    protocol: 'http',
                },
                action: {
                    type: 'socket-handler',
                },
                security: {
                    ipBlockList: ['0.0.0.0/0'],
                },
            },
        ]);
        get filteredRoutes() {
            if (this.currentTab === 'all')
                return this.demoRoutes;
            if (this.currentTab === 'https') {
                return this.demoRoutes.filter((r) => r.tags?.some((t) => ['web', 'https', 'http'].includes(t)));
            }
            if (this.currentTab === 'email') {
                return this.demoRoutes.filter((r) => r.tags?.some((t) => ['email', 'smtp'].includes(t)));
            }
            if (this.currentTab === 'dns') {
                return this.demoRoutes.filter((r) => r.tags?.some((t) => ['dns'].includes(t)));
            }
            return this.demoRoutes;
        }
        async onActivate(context) {
            this.appui = context.appui;
            this.appui.setContentTabs([
                {
                    key: 'All Routes',
                    action: () => {
                        this.currentTab = 'all';
                        this.updateSecondaryMenu();
                    },
                },
                {
                    key: 'HTTP/S',
                    action: () => {
                        this.currentTab = 'https';
                        this.updateSecondaryMenu();
                    },
                },
                {
                    key: 'Email',
                    action: () => {
                        this.currentTab = 'email';
                        this.updateSecondaryMenu();
                    },
                },
                {
                    key: 'DNS',
                    action: () => {
                        this.currentTab = 'dns';
                        this.updateSecondaryMenu();
                    },
                },
            ]);
            this.updateSecondaryMenu();
        }
        updateSecondaryMenu() {
            if (!this.appui)
                return;
            const total = this.demoRoutes.length;
            const active = this.demoRoutes.filter((r) => r.enabled !== false).length;
            const forwardCount = this.demoRoutes.filter((r) => r.action.type === 'forward').length;
            this.appui.setSecondaryMenu({
                heading: 'Routes',
                groups: [
                    {
                        name: 'Actions',
                        items: [
                            {
                                type: 'action',
                                key: 'Refresh',
                                iconName: 'lucide:RefreshCw',
                                action: () => {
                                    console.log('Refresh routes');
                                },
                            },
                            {
                                type: 'action',
                                key: 'Add Route',
                                iconName: 'lucide:Plus',
                                action: () => {
                                    console.log('Add route');
                                },
                            },
                        ],
                    },
                    {
                        name: 'Statistics',
                        items: [
                            { type: 'header', label: `${total} Total Routes` },
                            { type: 'header', label: `${active} Active` },
                            { type: 'header', label: `${forwardCount} Forward` },
                            { type: 'header', label: `${total - forwardCount} Socket Handler` },
                        ],
                    },
                ],
            });
        }
        onDeactivate() {
            // Cleanup if needed
        }
        static styles = [
            cssManager.defaultStyles,
            css `
      :host {
        display: block;
        padding: 24px;
        height: 100%;
        overflow-y: auto;
        box-sizing: border-box;
      }
    `,
        ];
        render() {
            return html `
      <sz-route-list-view
        .routes=${this.filteredRoutes}
        @route-click=${(e) => {
                console.log('Route clicked:', e.detail.name);
            }}
      ></sz-route-list-view>
    `;
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return SzDemoViewRoutes = _classThis;
})();
export { SzDemoViewRoutes };
//# sourceMappingURL=data:application/json;base64, 