var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { html, customElement, state } from '../../../../../external/lit/index.js';
import { createExtensionElement } from '../../../../../libs/extension-api/index.js';
import { umbExtensionsRegistry } from '../../../../core/extension-registry/index.js';
import { UmbLitElement } from '../../../../core/lit-element/index.js';
let UmbCreatedPackagesSectionViewElement = class UmbCreatedPackagesSectionViewElement extends UmbLitElement {
    #workspaces;
    constructor() {
        super();
        this._routes = [];
        this.#workspaces = [];
        this.observe(umbExtensionsRegistry.byTypeAndFilter('workspace', (workspace) => workspace.meta.entityType === 'package-builder'), (workspaceExtensions) => {
            this.#workspaces = workspaceExtensions;
            this._createRoutes();
        });
    }
    _createRoutes() {
        const routes = [
            {
                path: 'overview',
                component: () => import('./packages-created-overview.element.js'),
            },
        ];
        // TODO: find a way to make this reuseable across:
        this.#workspaces?.map((workspace) => {
            routes.push({
                path: `${workspace.meta.entityType}/:unique`,
                component: () => createExtensionElement(workspace),
                setup: (component, info) => {
                    if (component) {
                        component.entityUnique = info.match.params.unique;
                    }
                },
            });
            routes.push({
                path: workspace.meta.entityType,
                component: () => createExtensionElement(workspace),
            });
        });
        routes.push({
            path: '',
            pathMatch: 'full',
            redirectTo: 'overview',
        });
        routes.push({
            path: `**`,
            component: async () => (await import('../../../../core/router/index.js')).UmbRouteNotFoundElement,
        });
        this._routes = routes;
    }
    render() {
        return html `<umb-router-slot .routes=${this._routes}></umb-router-slot>`;
    }
};
__decorate([
    state()
], UmbCreatedPackagesSectionViewElement.prototype, "_routes", void 0);
UmbCreatedPackagesSectionViewElement = __decorate([
    customElement('umb-created-packages-section-view')
], UmbCreatedPackagesSectionViewElement);
export { UmbCreatedPackagesSectionViewElement };
export default UmbCreatedPackagesSectionViewElement;
