import { UmbLanguageDetailRepository } from '../../repository/index.js';
import { UMB_LANGUAGE_DETAIL_REPOSITORY_ALIAS } from '../../constants.js';
import { UMB_LANGUAGE_ENTITY_TYPE, UMB_LANGUAGE_ROOT_ENTITY_TYPE } from '../../entity.js';
import { UmbLanguageWorkspaceEditorElement } from './language-workspace-editor.element.js';
import { UMB_LANGUAGE_WORKSPACE_ALIAS } from './constants.js';
import { UmbWorkspaceIsNewRedirectController, UmbWorkspaceIsNewRedirectControllerAlias, UmbEntityNamedDetailWorkspaceContextBase, } from '../../../core/workspace/index.js';
export class UmbLanguageWorkspaceContext extends UmbEntityNamedDetailWorkspaceContextBase {
    constructor(host) {
        super(host, {
            workspaceAlias: UMB_LANGUAGE_WORKSPACE_ALIAS,
            entityType: UMB_LANGUAGE_ENTITY_TYPE,
            detailRepositoryAlias: UMB_LANGUAGE_DETAIL_REPOSITORY_ALIAS,
        });
        this.repository = new UmbLanguageDetailRepository(this);
        this.routes.setRoutes([
            {
                path: 'create',
                component: UmbLanguageWorkspaceEditorElement,
                setup: async () => {
                    await this.createScaffold({ parent: { entityType: UMB_LANGUAGE_ROOT_ENTITY_TYPE, unique: null } });
                    new UmbWorkspaceIsNewRedirectController(this, this, this.getHostElement().shadowRoot.querySelector('umb-router-slot'));
                },
            },
            {
                path: 'edit/:unique',
                component: UmbLanguageWorkspaceEditorElement,
                setup: (_component, info) => {
                    this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
                    this.load(info.match.params.unique);
                },
            },
        ]);
    }
    setCulture(unique) {
        this._data.updateCurrent({ unique });
    }
    setMandatory(isMandatory) {
        this._data.updateCurrent({ isMandatory });
    }
    setDefault(isDefault) {
        this._data.updateCurrent({ isDefault });
    }
    setFallbackCulture(unique) {
        this._data.updateCurrent({ fallbackIsoCode: unique });
    }
}
export { UmbLanguageWorkspaceContext as api };
