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, property, } from '@design.estate/dees-element';
let SzTrafficCard = (() => {
    let _classDecorators = [customElement('sz-traffic-card')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _data_decorators;
    let _data_initializers = [];
    let _data_extraInitializers = [];
    var SzTrafficCard = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _data_decorators = [property({ type: Object })];
            __esDecorate(this, null, _data_decorators, { kind: "accessor", name: "data", static: false, private: false, access: { has: obj => "data" in obj, get: obj => obj.data, set: (obj, value) => { obj.data = value; } }, metadata: _metadata }, _data_initializers, _data_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            SzTrafficCard = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        static demo = () => html `
    <div style="padding: 24px; max-width: 500px;">
      <sz-traffic-card
        .data=${{
            requests: 1250,
            errors: 15,
            errorPercent: 1.2,
            avgResponse: 145,
            reqPerMin: 21,
            status2xx: 85,
            status3xx: 5,
            status4xx: 8,
            status5xx: 2,
        }}
      ></sz-traffic-card>
    </div>
  `;
        #data_accessor_storage = __runInitializers(this, _data_initializers, {
            requests: 0,
            errors: 0,
            errorPercent: 0,
            avgResponse: 0,
            reqPerMin: 0,
            status2xx: 0,
            status3xx: 0,
            status4xx: 0,
            status5xx: 0,
        });
        get data() { return this.#data_accessor_storage; }
        set data(value) { this.#data_accessor_storage = value; }
        static styles = [
            cssManager.defaultStyles,
            css `
      :host {
        display: block;
        height: 100%;
      }

      .card {
        background: ${cssManager.bdTheme('#ffffff', '#09090b')};
        border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
        border-radius: 8px;
        padding: 20px;
        height: 100%;
        box-sizing: border-box;
      }

      .header {
        margin-bottom: 16px;
      }

      .title {
        font-size: 16px;
        font-weight: 600;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
      }

      .subtitle {
        font-size: 13px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
        margin-top: 2px;
      }

      .metrics {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        margin-bottom: 16px;
      }

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

      .metric-label {
        font-size: 13px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
      }

      .metric-value {
        font-size: 18px;
        font-weight: 600;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
      }

      .status-bar-container {
        padding-top: 12px;
        border-top: 1px solid ${cssManager.bdTheme('#f4f4f5', '#27272a')};
      }

      .status-bar {
        display: flex;
        height: 8px;
        border-radius: 4px;
        overflow: hidden;
        background: ${cssManager.bdTheme('#f4f4f5', '#27272a')};
        margin-bottom: 8px;
      }

      .status-segment {
        height: 100%;
        transition: width 300ms ease;
      }

      .status-2xx {
        background: ${cssManager.bdTheme('#22c55e', '#22c55e')};
      }

      .status-3xx {
        background: ${cssManager.bdTheme('#3b82f6', '#60a5fa')};
      }

      .status-4xx {
        background: ${cssManager.bdTheme('#facc15', '#facc15')};
      }

      .status-5xx {
        background: ${cssManager.bdTheme('#ef4444', '#ef4444')};
      }

      .status-legend {
        display: flex;
        justify-content: space-between;
      }

      .legend-item {
        font-size: 12px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
      }
    `,
        ];
        render() {
            const total = this.data.status2xx + this.data.status3xx + this.data.status4xx + this.data.status5xx;
            const p2xx = total > 0 ? (this.data.status2xx / total) * 100 : 0;
            const p3xx = total > 0 ? (this.data.status3xx / total) * 100 : 0;
            const p4xx = total > 0 ? (this.data.status4xx / total) * 100 : 0;
            const p5xx = total > 0 ? (this.data.status5xx / total) * 100 : 0;
            return html `
      <div class="card">
        <div class="header">
          <div class="title">Traffic (Last Hour)</div>
          <div class="subtitle">Request metrics from access logs</div>
        </div>

        <div class="metrics">
          <div class="metric">
            <span class="metric-label">Requests</span>
            <span class="metric-value">${this.formatNumber(this.data.requests)}</span>
          </div>
          <div class="metric">
            <span class="metric-label">Errors</span>
            <span class="metric-value">${this.data.errors} (${this.data.errorPercent}%)</span>
          </div>
          <div class="metric">
            <span class="metric-label">Avg Response</span>
            <span class="metric-value">${this.data.avgResponse}ms</span>
          </div>
          <div class="metric">
            <span class="metric-label">Req/min</span>
            <span class="metric-value">${this.data.reqPerMin}</span>
          </div>
        </div>

        <div class="status-bar-container">
          <div class="status-bar">
            <div class="status-segment status-2xx" style="width: ${p2xx}%"></div>
            <div class="status-segment status-3xx" style="width: ${p3xx}%"></div>
            <div class="status-segment status-4xx" style="width: ${p4xx}%"></div>
            <div class="status-segment status-5xx" style="width: ${p5xx}%"></div>
          </div>
          <div class="status-legend">
            <span class="legend-item">2xx</span>
            <span class="legend-item">3xx</span>
            <span class="legend-item">4xx</span>
            <span class="legend-item">5xx</span>
          </div>
        </div>
      </div>
    `;
        }
        formatNumber(num) {
            if (num >= 1000000)
                return (num / 1000000).toFixed(1) + 'M';
            if (num >= 1000)
                return (num / 1000).toFixed(1) + 'K';
            return num.toString();
        }
        constructor() {
            super(...arguments);
            __runInitializers(this, _data_extraInitializers);
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return SzTrafficCard = _classThis;
})();
export { SzTrafficCard };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3otdHJhZmZpYy1jYXJkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHNfd2ViL2VsZW1lbnRzL3N6LXRyYWZmaWMtY2FyZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsT0FBTyxFQUNMLFdBQVcsRUFDWCxhQUFhLEVBQ2IsSUFBSSxFQUNKLEdBQUcsRUFDSCxVQUFVLEVBQ1YsUUFBUSxHQUVULE1BQU0sNkJBQTZCLENBQUM7SUFxQnhCLGFBQWE7NEJBRHpCLGFBQWEsQ0FBQyxpQkFBaUIsQ0FBQzs7OztzQkFDRSxXQUFXOzs7OzZCQUFuQixT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