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 { LitElement, html, css, property, customElement } from './plugins.js';
import { sharedStyles, tableStyles } from './sw-dash-styles.js';
import { SwDashTable } from './sw-dash-table.js';
/**
 * URLs table view component
 */
let SwDashUrls = (() => {
    let _classDecorators = [customElement('sw-dash-urls')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = LitElement;
    let _resources_decorators;
    let _resources_initializers = [];
    let _resources_extraInitializers = [];
    var SwDashUrls = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _resources_decorators = [property({ type: Array })];
            __esDecorate(this, null, _resources_decorators, { kind: "accessor", name: "resources", static: false, private: false, access: { has: obj => "resources" in obj, get: obj => obj.resources, set: (obj, value) => { obj.resources = value; } }, metadata: _metadata }, _resources_initializers, _resources_extraInitializers);
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            SwDashUrls = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        static styles = [
            sharedStyles,
            tableStyles,
            css `
      :host {
        display: block;
      }
    `
        ];
        #resources_accessor_storage = __runInitializers(this, _resources_initializers, []);
        get resources() { return this.#resources_accessor_storage; }
        set resources(value) { this.#resources_accessor_storage = value; }
        columns = (__runInitializers(this, _resources_extraInitializers), [
            { key: 'url', label: 'URL', className: 'url' },
            { key: 'contentType', label: 'Type' },
            { key: 'size', label: 'Size', className: 'num', formatter: SwDashTable.formatBytes },
            { key: 'hitCount', label: 'Hits', className: 'num', formatter: SwDashTable.formatNumber },
            { key: 'missCount', label: 'Misses', className: 'num', formatter: SwDashTable.formatNumber },
            { key: 'hitRate', label: 'Hit Rate' },
            { key: 'lastAccessed', label: 'Last Access', formatter: SwDashTable.formatTimestamp },
        ]);
        getDataWithHitRate() {
            return this.resources.map(r => {
                const total = r.hitCount + r.missCount;
                return {
                    ...r,
                    hitRate: total > 0 ? Math.round((r.hitCount / total) * 100) : 0
                };
            });
        }
        render() {
            return html `
      <sw-dash-table
        .columns="${this.columns}"
        .data="${this.getDataWithHitRate()}"
        filterPlaceholder="Filter URLs..."
        infoLabel="resources"
      ></sw-dash-table>
    `;
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers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