import { UMB_SECTION_CONTEXT } from '../../section.context.token.js';
import { UmbConditionBase } from '../../../extension-registry/index.js';
export class UmbSectionAliasCondition extends UmbConditionBase {
    constructor(host, args) {
        super(host, args);
        let permissionCheck = undefined;
        if (this.config.match) {
            permissionCheck = (sectionAlias) => sectionAlias === this.config.match;
        }
        else if (this.config.oneOf) {
            permissionCheck = (sectionAlias) => this.config.oneOf.indexOf(sectionAlias) !== -1;
        }
        if (permissionCheck !== undefined) {
            this.consumeContext(UMB_SECTION_CONTEXT, (context) => {
                this.observe(context?.alias, (sectionAlias) => {
                    this.permitted = sectionAlias ? permissionCheck(sectionAlias) : false;
                }, 'observeAlias');
            });
        }
    }
}
