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 * as shared from './shared/index.js';
import * as appstate from '../appstate.js';
import { appRouter } from '../router.js';
import { DeesElement, customElement, html, state, css, cssManager, } from '@design.estate/dees-element';
let ObViewRegistries = (() => {
    let _classDecorators = [customElement('ob-view-registries')];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = DeesElement;
    let _registriesState_decorators;
    let _registriesState_initializers = [];
    let _registriesState_extraInitializers = [];
    let _currentTab_decorators;
    let _currentTab_initializers = [];
    let _currentTab_extraInitializers = [];
    var ObViewRegistries = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _registriesState_decorators = [state()];
            _currentTab_decorators = [state()];
            __esDecorate(this, null, _registriesState_decorators, { kind: "accessor", name: "registriesState", static: false, private: false, access: { has: obj => "registriesState" in obj, get: obj => obj.registriesState, set: (obj, value) => { obj.registriesState = value; } }, metadata: _metadata }, _registriesState_initializers, _registriesState_extraInitializers);
            __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);
            ObViewRegistries = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        #registriesState_accessor_storage = __runInitializers(this, _registriesState_initializers, {
            tokens: [],
            registryStatus: null,
        });
        get registriesState() { return this.#registriesState_accessor_storage; }
        set registriesState(value) { this.#registriesState_accessor_storage = value; }
        #currentTab_accessor_storage = (__runInitializers(this, _registriesState_extraInitializers), __runInitializers(this, _currentTab_initializers, 'onebox'));
        get currentTab() { return this.#currentTab_accessor_storage; }
        set currentTab(value) { this.#currentTab_accessor_storage = value; }
        constructor() {
            super();
            __runInitializers(this, _currentTab_extraInitializers);
            const registriesSub = appstate.registriesStatePart
                .select((s) => s)
                .subscribe((newState) => {
                this.registriesState = newState;
            });
            this.rxSubscriptions.push(registriesSub);
        }
        static styles = [
            cssManager.defaultStyles,
            shared.viewHostCss,
            css ``,
        ];
        async connectedCallback() {
            super.connectedCallback();
            await appstate.dispatchProtectedAction(appstate.fetchRegistryTokensAction, null);
        }
        render() {
            switch (this.currentTab) {
                case 'external':
                    return this.renderExternalView();
                default:
                    return this.renderOneboxView();
            }
        }
        renderOneboxView() {
            return html `
      <ob-sectionheading>Registries</ob-sectionheading>
      <sz-registry-advertisement
        .status=${'running'}
        .registryUrl=${'localhost:5000'}
        @manage-tokens=${() => {
                // tokens are managed via the tokens view
                appRouter.navigateToView('tokens');
            }}
      ></sz-registry-advertisement>
    `;
        }
        renderExternalView() {
            return html `
      <ob-sectionheading>External Registries</ob-sectionheading>
      <sz-registry-external-view
        .registries=${[]}
        @add=${(e) => {
                console.log('Add external registry:', e.detail);
            }}
      ></sz-registry-external-view>
    `;
        }
        static {
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return ObViewRegistries = _classThis;
})();
export { ObViewRegistries };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib2Itdmlldy1yZWdpc3RyaWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vdHNfd2ViL2VsZW1lbnRzL29iLXZpZXctcmVnaXN0cmllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxLQUFLLE1BQU0sTUFBTSxtQkFBbUIsQ0FBQztBQUM1QyxPQUFPLEtBQUssUUFBUSxNQUFNLGdCQUFnQixDQUFDO0FBQzNDLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFDekMsT0FBTyxFQUNMLFdBQVcsRUFDWCxhQUFhLEVBQ2IsSUFBSSxFQUNKLEtBQUssRUFDTCxHQUFHLEVBQ0gsVUFBVSxHQUVYLE1BQU0sNkJBQ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