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 plugins from '../../plugins.js';
import { DeesElement, property, html, customElement, css, cssManager, unsafeCSS, state, } from '@design.estate/dees-element';
import * as sharedStyles from '../../styles/shared.styles.js';
import { demoFunc } from './upladmin-monitor-list.demo.js';
let UpladminMonitorList = (() => {
    let _classDecorators = [customElement('upladmin-monitor-list')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _monitors_decorators;
    let _monitors_initializers = [];
    let _monitors_extraInitializers = [];
    let _loading_decorators;
    let _loading_initializers = [];
    let _loading_extraInitializers = [];
    let _statusFilter_decorators;
    let _statusFilter_initializers = [];
    let _statusFilter_extraInitializers = [];
    let _categoryFilter_decorators;
    let _categoryFilter_initializers = [];
    let _categoryFilter_extraInitializers = [];
    var UpladminMonitorList = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _monitors_decorators = [property({ type: Array })];
            _loading_decorators = [property({ type: Boolean })];
            _statusFilter_decorators = [state()];
            _categoryFilter_decorators = [state()];
            __esDecorate(this, null, _monitors_decorators, { kind: "accessor", name: "monitors", static: false, private: false, access: { has: obj => "monitors" in obj, get: obj => obj.monitors, set: (obj, value) => { obj.monitors = value; } }, metadata: _metadata }, _monitors_initializers, _monitors_extraInitializers);
            __esDecorate(this, null, _loading_decorators, { kind: "accessor", name: "loading", static: false, private: false, access: { has: obj => "loading" in obj, get: obj => obj.loading, set: (obj, value) => { obj.loading = value; } }, metadata: _metadata }, _loading_initializers, _loading_extraInitializers);
            __esDecorate(this, null, _statusFilter_decorators, { kind: "accessor", name: "statusFilter", static: false, private: false, access: { has: obj => "statusFilter" in obj, get: obj => obj.statusFilter, set: (obj, value) => { obj.statusFilter = value; } }, metadata: _metadata }, _statusFilter_initializers, _statusFilter_extraInitializers);
            __esDecorate(this, null, _categoryFilter_decorators, { kind: "accessor", name: "categoryFilter", static: false, private: false, access: { has: obj => "categoryFilter" in obj, get: obj => obj.categoryFilter, set: (obj, value) => { obj.categoryFilter = value; } }, metadata: _metadata }, _categoryFilter_initializers, _categoryFilter_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            UpladminMonitorList = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        static demo = demoFunc;
        #monitors_accessor_storage = __runInitializers(this, _monitors_initializers, []);
        get monitors() { return this.#monitors_accessor_storage; }
        set monitors(value) { this.#monitors_accessor_storage = value; }
        #loading_accessor_storage = (__runInitializers(this, _monitors_extraInitializers), __runInitializers(this, _loading_initializers, false));
        get loading() { return this.#loading_accessor_storage; }
        set loading(value) { this.#loading_accessor_storage = value; }
        #statusFilter_accessor_storage = (__runInitializers(this, _loading_extraInitializers), __runInitializers(this, _statusFilter_initializers, 'all'));
        get statusFilter() { return this.#statusFilter_accessor_storage; }
        set statusFilter(value) { this.#statusFilter_accessor_storage = value; }
        #categoryFilter_accessor_storage = (__runInitializers(this, _statusFilter_extraInitializers), __runInitializers(this, _categoryFilter_initializers, 'all'));
        get categoryFilter() { return this.#categoryFilter_accessor_storage; }
        set categoryFilter(value) { this.#categoryFilter_accessor_storage = value; }
        statusIcons = (__runInitializers(this, _categoryFilter_extraInitializers), {
            operational: 'lucide:CheckCircle',
            degraded: 'lucide:AlertTriangle',
            partial_outage: 'lucide:AlertOctagon',
            major_outage: 'lucide:XCircle',
            maintenance: 'lucide:Wrench',
        });
        statusLabels = {
            operational: 'Operational',
            degraded: 'Degraded',
            partial_outage: 'Partial Outage',
            major_outage: 'Major Outage',
            maintenance: 'Maintenance',
        };
        static styles = [
            plugins.domtools.elementBasic.staticStyles,
            sharedStyles.commonStyles,
            css `
      :host {
        display: block;
        font-family: ${unsafeCSS(sharedStyles.fonts.base)};
      }

      .list-container {
        background: ${sharedStyles.colors.background.secondary};
        border: 1px solid ${sharedStyles.colors.border.default};
        border-radius: ${unsafeCSS(sharedStyles.borderRadius.lg)};
        overflow: hidden;
        position: relative;
      }

      .list-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: ${unsafeCSS(sharedStyles.spacing.md)};
        padding: ${unsafeCSS(sharedStyles.spacing.md)} ${unsafeCSS(sharedStyles.spacing.lg)};
        border-bottom: 1px solid ${sharedStyles.colors.border.default};
        flex-wrap: wrap;
      }

      .list-title {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 16px;
        font-weight: 600;
        color: ${sharedStyles.colors.text.primary};
      }

      .list-title dees-icon {
        --icon-color: ${cssManager.bdTheme('#3b82f6', '#60a5fa')};
      }

      .list-controls {
        display: flex;
        align-items: center;
        gap: ${unsafeCSS(sharedStyles.spacing.sm)};
        flex-wrap: wrap;
      }

      .filter-select {
        padding: 10px 32px 10px 12px;
        font-size: 13px;
        font-family: ${unsafeCSS(sharedStyles.fonts.base)};
        color: ${sharedStyles.colors.text.primary};
        background: ${sharedStyles.colors.background.primary};
        border: 1px solid ${sharedStyles.colors.border.default};
        border-radius: ${unsafeCSS(sharedStyles.borderRadius.base)};
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
        transition: all ${unsafeCSS(sharedStyles.durations.fast)} ${unsafeCSS(sharedStyles.easings.default)};
      }

      .filter-select:focus {
        outline: none;
        border-color: ${sharedStyles.colors.accent.primary};
        box-shadow: 0 0 0 3px ${cssManager.bdTheme('rgba(59, 130, 246, 0.1)', 'rgba(96, 165, 250, 0.15)')};
      }

      .table-container {
        padding: 0;
      }

      dees-table {
        --dees-table-background: transparent;
        --dees-table-border: none;
      }

      dees-table::part(mainbox) {
        border: none;
        border-radius: 0;
      }

      .status-badge {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 6px 12px;
        font-size: 12px;
        font-weight: 500;
        border-radius: 9999px;
        white-space: nowrap;
      }

      .status-badge dees-icon {
        font-size: 14px;
      }

      .status-badge.operational {
        background: ${cssManager.bdTheme('rgba(34, 197, 94, 0.1)', 'rgba(34, 197, 94, 0.15)')};
        color: ${sharedStyles.colors.status.operational};
        --icon-color: ${sharedStyles.colors.status.operational};
      }

      .status-badge.degraded {
        background: ${cssManager.bdTheme('rgba(234, 179, 8, 0.1)', 'rgba(234, 179, 8, 0.15)')};
        color: ${sharedStyles.colors.status.degraded};
        --icon-color: ${sharedStyles.colors.status.degraded};
      }

      .status-badge.partial_outage {
        background: ${cssManager.bdTheme('rgba(249, 115, 22, 0.1)', 'rgba(249, 115, 22, 0.15)')};
        color: ${sharedStyles.colors.status.partialOutage};
        --icon-color: ${sharedStyles.colors.status.partialOutage};
      }

      .status-badge.major_outage {
        background: ${cssManager.bdTheme('rgba(239, 68, 68, 0.1)', 'rgba(239, 68, 68, 0.15)')};
        color: ${sharedStyles.colors.status.majorOutage};
        --icon-color: ${sharedStyles.colors.status.majorOutage};
      }

      .status-badge.maintenance {
        background: ${cssManager.bdTheme('rgba(59, 130, 246, 0.1)', 'rgba(59, 130, 246, 0.15)')};
        color: ${sharedStyles.colors.status.maintenance};
        --icon-color: ${sharedStyles.colors.status.maintenance};
      }

      .monitor-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
      }

      .monitor-name {
        font-weight: 600;
        color: ${sharedStyles.colors.text.primary};
      }

      .monitor-id {
        font-size: 12px;
        color: ${sharedStyles.colors.text.muted};
        font-family: ${unsafeCSS(sharedStyles.fonts.mono)};
      }

      .uptime-value {
        font-family: ${unsafeCSS(sharedStyles.fonts.mono)};
        font-size: 13px;
        font-weight: 500;
      }

      .uptime-value.good {
        color: ${sharedStyles.colors.status.operational};
      }

      .uptime-value.warning {
        color: ${sharedStyles.colors.status.degraded};
      }

      .uptime-value.bad {
        color: ${sharedStyles.colors.status.majorOutage};
      }

      .category-tag {
        display: inline-block;
        padding: 4px 10px;
        font-size: 11px;
        font-weight: 500;
        background: ${sharedStyles.colors.background.muted};
        color: ${sharedStyles.colors.text.secondary};
        border-radius: ${unsafeCSS(sharedStyles.borderRadius.sm)};
      }

      .empty-state {
        padding: 64px 24px;
        text-align: center;
      }

      .empty-state dees-icon {
        --icon-color: ${sharedStyles.colors.text.muted};
        opacity: 0.4;
        margin-bottom: 20px;
      }

      .empty-title {
        font-size: 16px;
        font-weight: 600;
        color: ${sharedStyles.colors.text.primary};
        margin-bottom: 8px;
      }

      .empty-text {
        font-size: 14px;
        color: ${sharedStyles.colors.text.muted};
        margin-bottom: 24px;
      }

      .loading-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: ${cssManager.bdTheme('rgba(255,255,255,0.9)', 'rgba(0,0,0,0.7)')};
        z-index: 10;
        backdrop-filter: blur(2px);
      }

      .loading-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        color: ${sharedStyles.colors.text.secondary};
        font-size: 14px;
      }

      .no-category {
        color: ${sharedStyles.colors.text.muted};
      }
    `
        ];
        get filteredMonitors() {
            let result = [...this.monitors];
            // Status filter
            if (this.statusFilter !== 'all') {
                result = result.filter(m => m.currentStatus === this.statusFilter);
            }
            // Category filter
            if (this.categoryFilter !== 'all') {
                result = result.filter(m => m.category === this.categoryFilter);
            }
            return result;
        }
        get categories() {
            return [...new Set(this.monitors.map(m => m.category).filter(Boolean))];
        }
        get tableColumns() {
            return [
                {
                    key: 'name',
                    header: 'Name',
                    sortable: true,
                    renderer: (value, item) => html `
          <div class="monitor-info">
            <span class="monitor-name">${item.displayName || item.name}</span>
            <span class="monitor-id">${item.id}</span>
          </div>
        `,
                },
                {
                    key: 'currentStatus',
                    header: 'Status',
                    sortable: true,
                    renderer: (value, item) => html `
          <span class="status-badge ${item.currentStatus}">
            <dees-icon .icon=${this.statusIcons[item.currentStatus]} .iconSize=${14}></dees-icon>
            ${this.statusLabels[item.currentStatus]}
          </span>
        `,
                },
                {
                    key: 'uptime30d',
                    header: 'Uptime (30d)',
                    sortable: true,
                    renderer: (value, item) => {
                        const uptimeClass = item.uptime30d >= 99.9 ? 'good' : item.uptime30d >= 99 ? 'warning' : 'bad';
                        return html `<span class="uptime-value ${uptimeClass}">${item.uptime30d.toFixed(2)}%</span>`;
                    },
                },
                {
                    key: 'category',
                    header: 'Category',
                    sortable: true,
                    renderer: (value, item) => item.category
                        ? html `<span class="category-tag">${item.category}</span>`
                        : html `<span class="no-category">—</span>`,
                },
            ];
        }
        get tableActions() {
            return [
                {
                    name: 'Edit',
                    iconName: 'lucide:Pencil',
                    type: ['inRow'],
                    actionFunc: async ({ item }) => {
                        this.handleEdit(item);
                    },
                },
                {
                    name: 'Delete',
                    iconName: 'lucide:Trash2',
                    type: ['inRow'],
                    actionFunc: async ({ item }) => {
                        this.handleDelete(item);
                    },
                },
            ];
        }
        render() {
            const filteredMonitors = this.filteredMonitors;
            return html `
      <div class="list-container">
        ${this.loading ? html `
          <div class="loading-overlay">
            <div class="loading-content">
              <dees-spinner></dees-spinner>
              <span>Loading monitors...</span>
            </div>
          </div>
        ` : ''}

        <div class="list-header">
          <span class="list-title">
            <dees-icon .icon=${'lucide:Activity'}></dees-icon>
            Monitors (${filteredMonitors.length})
          </span>

          <div class="list-controls">
            <select class="filter-select" @change="${this.handleStatusFilter}">
              <option value="all" ?selected="${this.statusFilter === 'all'}">All Statuses</option>
              <option value="operational" ?selected="${this.statusFilter === 'operational'}">Operational</option>
              <option value="degraded" ?selected="${this.statusFilter === 'degraded'}">Degraded</option>
              <option value="partial_outage" ?selected="${this.statusFilter === 'partial_outage'}">Partial Outage</option>
              <option value="major_outage" ?selected="${this.statusFilter === 'major_outage'}">Major Outage</option>
              <option value="maintenance" ?selected="${this.statusFilter === 'maintenance'}">Maintenance</option>
            </select>

            ${this.categories.length > 0 ? html `
              <select class="filter-select" @change="${this.handleCategoryFilter}">
                <option value="all" ?selected="${this.categoryFilter === 'all'}">All Categories</option>
                ${this.categories.map(cat => html `
                  <option value="${cat}" ?selected="${this.categoryFilter === cat}">${cat}</option>
                `)}
              </select>
            ` : ''}

            <dees-button
              type="highlighted"
              @click="${this.handleAddClick}"
            >
              <dees-icon .icon=${'lucide:Plus'} .iconSize=${16}></dees-icon>
              Add Monitor
            </dees-button>
          </div>
        </div>

        <div class="table-container">
          ${filteredMonitors.length > 0 ? html `
            <dees-table
              .heading1=${''}
              .heading2=${''}
              .data=${filteredMonitors}
              .dataName=${'monitors'}
              .columns=${this.tableColumns}
              .dataActions=${this.tableActions}
              .searchable=${true}
              .showGrid=${false}
              .showHorizontalLines=${true}
              .rowKey=${'id'}
            ></dees-table>
          ` : html `
            <div class="empty-state">
              <dees-icon .icon=${'lucide:BarChart2'} .iconSize=${48}></dees-icon>
              <div class="empty-title">No monitors found</div>
              <div class="empty-text">
                ${this.statusFilter !== 'all' || this.categoryFilter !== 'all'
                ? 'Try adjusting your filters'
                : 'Add your first monitor to start tracking service status'}
              </div>
              ${this.statusFilter === 'all' && this.categoryFilter === 'all' ? html `
                <dees-button type="highlighted" @click="${this.handleAddClick}">
                  <dees-icon .icon=${'lucide:Plus'} .iconSize=${16}></dees-icon>
                  Add Your First Monitor
                </dees-button>
              ` : ''}
            </div>
          `}
        </div>
      </div>
    `;
        }
        handleStatusFilter(e) {
            this.statusFilter = e.target.value;
        }
        handleCategoryFilter(e) {
            this.categoryFilter = e.target.value;
        }
        handleAddClick() {
            this.dispatchEvent(new CustomEvent('monitorAdd', {
                bubbles: true,
                composed: true
            }));
        }
        handleEdit(monitor) {
            this.dispatchEvent(new CustomEvent('monitorEdit', {
                detail: { monitor },
                bubbles: true,
                composed: true
            }));
        }
        handleDelete(monitor) {
            this.dispatchEvent(new CustomEvent('monitorDelete', {
                detail: { monitor },
                bubbles: true,
                composed: true
            }));
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return UpladminMonitorList = _classThis;
})();
export { UpladminMonitorList };
//# sourceMappingURL=data:application/json;base64, 