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 { adminState } from '../../services/admin-state.js';
import { demoFunc } from './upladmin-app.demo.js';
// Import components directly
import '../../elements/upladmin-dashboard/upladmin-dashboard.js';
import '../../elements/upladmin-monitor-list/upladmin-monitor-list.js';
import '../../elements/upladmin-monitor-form/upladmin-monitor-form.js';
import '../../elements/upladmin-incident-list/upladmin-incident-list.js';
import '../../elements/upladmin-incident-form/upladmin-incident-form.js';
import '../../elements/upladmin-incident-update/upladmin-incident-update.js';
import '../../elements/upladmin-statuspage-config/upladmin-statuspage-config.js';
let UpladminApp = (() => {
    let _classDecorators = [customElement('upladmin-app')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _appuiBase_decorators;
    let _appuiBase_initializers = [];
    let _appuiBase_extraInitializers = [];
    var UpladminApp = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _appuiBase_decorators = [state()];
            __esDecorate(this, null, _appuiBase_decorators, { kind: "accessor", name: "appuiBase", static: false, private: false, access: { has: obj => "appuiBase" in obj, get: obj => obj.appuiBase, set: (obj, value) => { obj.appuiBase = value; } }, metadata: _metadata }, _appuiBase_initializers, _appuiBase_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            UpladminApp = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        static demo = demoFunc;
        #appuiBase_accessor_storage = __runInitializers(this, _appuiBase_initializers, null);
        get appuiBase() { return this.#appuiBase_accessor_storage; }
        set appuiBase(value) { this.#appuiBase_accessor_storage = value; }
        static styles = [
            cssManager.defaultStyles,
            css `
      :host {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    `,
        ];
        async firstUpdated() {
            await this.updateComplete;
            this.appuiBase = this.shadowRoot.querySelector('dees-appui-base');
            if (this.appuiBase) {
                await this.appuiBase.updateComplete;
                this.configureApp();
            }
        }
        configureApp() {
            if (!this.appuiBase)
                return;
            const appConfig = {
                branding: {
                    logoIcon: 'lucide:activity',
                    logoText: 'uptime.link',
                },
                appBar: {
                    menuItems: [
                        {
                            name: 'File',
                            action: async () => { },
                            submenu: [
                                {
                                    name: 'New Monitor',
                                    shortcut: 'Cmd+N',
                                    iconName: 'plus',
                                    action: async () => (window.location.hash = 'monitors/create'),
                                },
                                {
                                    name: 'New Incident',
                                    shortcut: 'Cmd+I',
                                    iconName: 'alertTriangle',
                                    action: async () => (window.location.hash = 'incidents/create'),
                                },
                                { divider: true },
                                {
                                    name: 'Reload Data',
                                    shortcut: 'Cmd+R',
                                    iconName: 'refreshCw',
                                    action: async () => this.reloadData(),
                                },
                            ],
                        },
                        {
                            name: 'View',
                            action: async () => { },
                            submenu: [
                                {
                                    name: 'Dashboard',
                                    iconName: 'layoutDashboard',
                                    action: async () => (window.location.hash = 'dashboard'),
                                },
                                {
                                    name: 'Monitors',
                                    iconName: 'activity',
                                    action: async () => (window.location.hash = 'monitors'),
                                },
                                {
                                    name: 'Incidents',
                                    iconName: 'alertCircle',
                                    action: async () => (window.location.hash = 'incidents'),
                                },
                                { divider: true },
                                {
                                    name: 'Settings',
                                    iconName: 'settings',
                                    action: async () => (window.location.hash = 'config'),
                                },
                            ],
                        },
                        {
                            name: 'Help',
                            action: async () => { },
                            submenu: [
                                {
                                    name: 'Documentation',
                                    iconName: 'book',
                                    action: async () => window.open('https://uptime.link/docs', '_blank'),
                                },
                                {
                                    name: 'API Reference',
                                    iconName: 'code',
                                    action: async () => window.open('https://uptime.link/api', '_blank'),
                                },
                                { divider: true },
                                {
                                    name: 'About uptime.link',
                                    iconName: 'info',
                                    action: async () => console.log('About'),
                                },
                            ],
                        },
                    ],
                    breadcrumbs: 'Dashboard',
                    showWindowControls: false,
                    showSearch: true,
                    user: {
                        name: 'Admin User',
                        email: 'admin@uptime.link',
                        status: 'online',
                    },
                    profileMenuItems: [
                        {
                            name: 'Profile',
                            iconName: 'user',
                            action: async () => console.log('Profile'),
                        },
                        {
                            name: 'Account Settings',
                            iconName: 'settings',
                            action: async () => (window.location.hash = 'config'),
                        },
                        { divider: true },
                        {
                            name: 'Sign Out',
                            iconName: 'logOut',
                            action: async () => console.log('Sign out'),
                        },
                    ],
                },
                views: [
                    {
                        id: 'dashboard',
                        name: 'Dashboard',
                        iconName: 'lucide:layoutDashboard',
                        content: 'upladmin-dashboard',
                        route: 'dashboard',
                    },
                    {
                        id: 'monitors',
                        name: 'Monitors',
                        iconName: 'lucide:activity',
                        content: 'upladmin-monitor-list',
                        route: 'monitors',
                        badge: adminState.monitors.length,
                    },
                    {
                        id: 'monitor-form',
                        name: 'Monitor',
                        iconName: 'lucide:activity',
                        content: 'upladmin-monitor-form',
                        route: 'monitors/:id',
                        cache: false,
                    },
                    {
                        id: 'incidents',
                        name: 'Incidents',
                        iconName: 'lucide:alertCircle',
                        content: 'upladmin-incident-list',
                        route: 'incidents',
                        badge: adminState.getActiveIncidents().length,
                        badgeVariant: adminState.getActiveIncidents().length > 0 ? 'warning' : 'default',
                    },
                    {
                        id: 'incident-form',
                        name: 'Incident',
                        iconName: 'lucide:alertCircle',
                        content: 'upladmin-incident-form',
                        route: 'incidents/:id',
                        cache: false,
                    },
                    {
                        id: 'incident-update',
                        name: 'Post Update',
                        iconName: 'lucide:messageSquarePlus',
                        content: 'upladmin-incident-update',
                        route: 'incidents/:id/update',
                        cache: false,
                    },
                    {
                        id: 'config',
                        name: 'Settings',
                        iconName: 'lucide:settings',
                        content: 'upladmin-statuspage-config',
                        route: 'config',
                    },
                ],
                mainMenu: {
                    sections: [
                        { name: 'Overview', views: ['dashboard'] },
                        { name: 'Management', views: ['monitors', 'incidents'] },
                    ],
                    bottomItems: ['config'],
                },
                defaultView: 'dashboard',
                onViewChange: (viewId, view) => {
                    console.log(`View changed to: ${viewId} (${view.name})`);
                },
                onSearch: (query) => {
                    console.log('Search query:', query);
                    // Implement search functionality
                },
            };
            this.appuiBase.configure(appConfig);
            // Update badges when state changes
            this.setupStateSubscriptions();
        }
        setupStateSubscriptions() {
            if (!this.appuiBase)
                return;
            const appui = this.appuiBase;
            adminState.monitors$.subscribe((monitors) => {
                appui.setMainMenuBadge('monitors', monitors.length);
            });
            adminState.incidents$.subscribe((incidents) => {
                const activeCount = incidents.filter((i) => !['resolved', 'postmortem'].includes(i.status)).length;
                appui.setMainMenuBadge('incidents', activeCount);
            });
        }
        async reloadData() {
            console.log('Reloading data...');
            // Implement data reload
        }
        render() {
            return html `<dees-appui-base></dees-appui-base>`;
        }
        constructor() {
            super(...arguments);
            __runInitializers(this, _appuiBase_extraInitializers);
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return UpladminApp = _classThis;
})();
export { UpladminApp };
//# sourceMappingURL=data:application/json;base64, 