import * as i0 from '@angular/core';
import { InjectionToken, inject, isDevMode, Injectable, ChangeDetectorRef, Inject, Optional, Directive, Input, HostBinding, TemplateRef, ViewContainerRef, INJECTOR, NgModule } from '@angular/core';
import { coerceArray } from '@rxap/utilities';
import { BehaviorSubject } from 'rxjs';
import { map, distinctUntilChanged, tap } from 'rxjs/operators';
import * as i2 from '@angular/forms';
import { NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
import { MatButton, MatIconButton, MatMiniFabButton, MatFabButton } from '@angular/material/button';
import * as i2$1 from '@angular/material/checkbox';
import { MatCheckbox } from '@angular/material/checkbox';
import * as i2$2 from '@angular/material/input';
import { MatInput } from '@angular/material/input';
import * as i2$3 from '@angular/material/select';
import { MatSelect } from '@angular/material/select';
import * as i2$4 from '@angular/material/slide-toggle';
import { MatSlideToggle } from '@angular/material/slide-toggle';

const RXAP_AUTHORIZATION_SCOPE = new InjectionToken('rxap-authorization/scope');
const RXAP_GET_SYSTEM_ROLES_METHOD = new InjectionToken('rxap-authorization/get-system-roles-method');
const RXAP_DISABLE_AUTHORIZATION = new InjectionToken('rxap-authorization/disable');

class AuthorizationService {
    constructor() {
        this.permissions$ = new BehaviorSubject([]);
        this.disabled = inject(RXAP_DISABLE_AUTHORIZATION, { optional: true }) ?? false;
    }
    setPermissions(permissions) {
        this.permissions$.next(permissions);
    }
    checkPermission(identifier, permissions, scope) {
        if (this.disabled) {
            console.warn('Authorization is disabled! Granting all permissions!');
            return true;
        }
        identifier = coerceArray(identifier);
        if (!identifier.length) {
            return true;
        }
        if (isDevMode()) {
            console.log(`check permission for [${identifier.join(', ')}]${scope ? ` with scope '${scope}': ` : ' :'}`, permissions);
        }
        // holds all permission, but if a scope is defined only permissions without scope
        // or with the matching scope and the scope prefix is removed
        let permissionSubset = permissions;
        if (scope) {
            permissionSubset = permissions
                .filter((permission) => !permission.match(/\//) ||
                permission.match(new RegExp(`^${scope.replace('.', '\\.')}/`))).map((permission) => permission.replace(new RegExp(`^${scope.replace('.', '\\.')}/`), '')).sort((a, b) => a.length - b.length);
        }
        if (identifier.every(id => permissionSubset.includes(id))) {
            return true;
        }
        const permissionRegexList = permissionSubset.map((permission) => {
            const permissionRegex = permission
                .replace('.', '\\.')
                .replace('*', '.+');
            if (permission[0] === '*' && permission[permission.length - 1] === '*') {
                return new RegExp(permissionRegex);
            }
            else if (permission[0] === '*') {
                return new RegExp(`${permissionRegex}$`);
            }
            else if (permission[permission.length - 1] === '*') {
                return new RegExp(`^${permissionRegex}`);
            }
            else {
                return new RegExp(`^${permissionRegex}$`);
            }
        });
        return identifier.every(id => permissionRegexList.some((permissionRegex) => id.match(permissionRegex)));
    }
    hasPermission$(identifier, scope, ignorePermissionList) {
        return this.permissions$.pipe(map((permissions) => ignorePermissionList ?
            permissions.filter((permission) => !ignorePermissionList.includes(permission)) :
            permissions.slice()), map((permissions) => this.checkPermission(identifier, permissions, scope)), distinctUntilChanged());
    }
    hasPermission(identifier, scope, ignorePermissionList) {
        const allPermissions = this.getPermissions();
        const permissions = ignorePermissionList ?
            allPermissions.filter((permission) => !ignorePermissionList.includes(permission)) :
            allPermissions;
        return this.checkPermission(identifier, permissions, scope);
    }
    getPermissions$() {
        return this.permissions$.asObservable().pipe(map(permissions => permissions.slice()));
    }
    getPermissions() {
        return this.permissions$.value.slice();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AuthorizationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AuthorizationService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AuthorizationService, decorators: [{
            type: Injectable,
            args: [{ providedIn: 'root' }]
        }] });

class HasEnablePermission {
    constructor(authorization, cdr, scope = null, valueAccessor = null) {
        this.authorization = authorization;
        this.cdr = cdr;
        this.scope = scope;
        this.valueAccessor = valueAccessor;
    }
    // eslint-disable-next-line @angular-eslint/contextual-lifecycle
    ngOnInit() {
        this._subscription = this
            .authorization
            .hasPermission$(this.identifier, this.scope || null)
            .pipe(tap((hasPermission) => {
            this.setDisabled(!hasPermission);
            if (this.valueAccessor) {
                this.valueAccessor.forEach((value) => {
                    if (value.setDisabledState) {
                        value.setDisabledState(!hasPermission);
                    }
                });
            }
            this.cdr.markForCheck();
            this.cdr.detectChanges();
        }))
            .subscribe();
    }
    ngOnDestroy() {
        this._subscription?.unsubscribe();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasEnablePermission, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasEnablePermission }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasEnablePermission, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }] });

class FormControlHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, scope, valueAccessor = null, ngControl) {
        super(authorization, cdr, scope, valueAccessor);
        this.ngControl = ngControl;
    }
    setDisabled(disabled) {
        if (this.ngControl.control) {
            if (disabled) {
                this.ngControl.control.disable();
            }
            else {
                this.ngControl.control.enable();
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: FormControlHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }, { token: NgControl }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: FormControlHasEnablePermissionDirective, isStandalone: true, selector: "[formControl][rxapHasEnablePermission],[formControlName][rxapHasEnablePermission]", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: FormControlHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[formControl][rxapHasEnablePermission],[formControlName][rxapHasEnablePermission]',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }, { type: i2.NgControl, decorators: [{
                    type: Inject,
                    args: [NgControl]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class HasWritePermissionDirective {
    constructor(authorization, cdr, scope = null) {
        this.authorization = authorization;
        this.cdr = cdr;
        this.scope = scope;
        this.readonly = false;
    }
    ngOnInit() {
        this._subscription = this.authorization
            .hasPermission$(this.identifier, this.scope || null)
            .pipe(tap((hasPermission) => {
            this.readonly = !hasPermission;
            this.cdr.markForCheck();
        }))
            .subscribe();
    }
    ngOnDestroy() {
        this._subscription?.unsubscribe();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasWritePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: HasWritePermissionDirective, isStandalone: true, selector: "[rxapHasWritePermission]", inputs: { identifier: ["rxapHasWritePermission", "identifier"] }, host: { properties: { "readonly": "this.readonly" } }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasWritePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[rxapHasWritePermission]',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: [{
                        alias: 'rxapHasWritePermission',
                        required: true,
                    }]
            }], readonly: [{
                type: HostBinding,
                args: ['readonly']
            }] } });

class IfHasPermissionDirective {
    constructor(authorization, template, viewContainerRef, cdr, scope = null) {
        this.authorization = authorization;
        this.template = template;
        this.viewContainerRef = viewContainerRef;
        this.cdr = cdr;
        this.scope = scope;
    }
    ngOnInit() {
        this._subscription = this.authorization
            .hasPermission$(this.identifier, this.scope || null)
            .pipe(distinctUntilChanged(), tap((hasPermission) => {
            this.viewContainerRef.clear();
            if (hasPermission) {
                this.viewContainerRef.createEmbeddedView(this.template);
            }
            else if (this.else) {
                this.viewContainerRef.createEmbeddedView(this.else);
            }
            this.cdr.markForCheck();
        }))
            .subscribe();
    }
    ngOnDestroy() {
        this._subscription?.unsubscribe();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: IfHasPermissionDirective, deps: [{ token: AuthorizationService }, { token: TemplateRef }, { token: ViewContainerRef }, { token: ChangeDetectorRef }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: IfHasPermissionDirective, isStandalone: true, selector: "[rxapIfHasPermission]", inputs: { identifier: ["rxapIfHasPermission", "identifier"], else: ["rxapIfHasPermissionElse", "else"] }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: IfHasPermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[rxapIfHasPermission]',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.TemplateRef, decorators: [{
                    type: Inject,
                    args: [TemplateRef]
                }] }, { type: i0.ViewContainerRef, decorators: [{
                    type: Inject,
                    args: [ViewContainerRef]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: [{ required: true, alias: 'rxapIfHasPermission' }]
            }], else: [{
                type: Input,
                args: [{ alias: 'rxapIfHasPermissionElse' }]
            }] } });

class MatButtonHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, injector, scope) {
        super(authorization, cdr, scope);
        this.injector = injector;
    }
    setDisabled(disabled) {
        this._button.disabled = disabled;
    }
    ngOnInit() {
        this._button = this.injector.get(MatButton, this.injector.get(MatIconButton, this.injector.get(MatMiniFabButton, this.injector.get(MatFabButton, null))));
        if (!this._button) {
            throw new Error('Could not inject the mat button instance!');
        }
        // must be called after the button is injected
        // the setDisabled method is called in the super.ngOnInit method
        super.ngOnInit();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatButtonHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: INJECTOR }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: MatButtonHasEnablePermissionDirective, isStandalone: true, selector: "button[rxapHasEnablePermission],[mat-button][rxapHasEnablePermission],[mat-raised-button][rxapHasEnablePermission],[mat-stroked-button][rxapHasEnablePermission],[mat-flat-button][rxapHasEnablePermission],[mat-icon-button][rxapHasEnablePermission],[mat-fab][rxapHasEnablePermission],[mat-mini-fab][rxapHasEnablePermission]", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatButtonHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'button[rxapHasEnablePermission],[mat-button][rxapHasEnablePermission],[mat-raised-button][rxapHasEnablePermission],[mat-stroked-button][rxapHasEnablePermission],[mat-flat-button][rxapHasEnablePermission],[mat-icon-button][rxapHasEnablePermission],[mat-fab][rxapHasEnablePermission],[mat-mini-fab][rxapHasEnablePermission]',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: i0.Injector, decorators: [{
                    type: Inject,
                    args: [INJECTOR]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class MatCheckboxHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, matCheckbox, scope, valueAccessor = null) {
        super(authorization, cdr, scope, valueAccessor);
        this.matCheckbox = matCheckbox;
    }
    setDisabled(disabled) {
        this.matCheckbox.disabled = disabled;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatCheckboxHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: MatCheckbox }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: MatCheckboxHasEnablePermissionDirective, isStandalone: true, selector: "mat-checkbox[rxapHasEnablePermission]:not([formControl]):not([formControlName])", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatCheckboxHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'mat-checkbox[rxapHasEnablePermission]:not([formControl]):not([formControlName])',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: i2$1.MatCheckbox, decorators: [{
                    type: Inject,
                    args: [MatCheckbox]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class MatInputHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, matInput, scope, valueAccessor = null) {
        super(authorization, cdr, scope, valueAccessor);
        this.matInput = matInput;
    }
    setDisabled(disabled) {
        this.matInput.disabled = disabled;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatInputHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: MatInput }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: MatInputHasEnablePermissionDirective, isStandalone: true, selector: "[matInput][rxapHasEnablePermission]:not([formControl]):not([formControlName])", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatInputHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[matInput][rxapHasEnablePermission]:not([formControl]):not([formControlName])',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: i2$2.MatInput, decorators: [{
                    type: Inject,
                    args: [MatInput]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class MatSelectHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, matSelect, scope, valueAccessor = null) {
        super(authorization, cdr, scope, valueAccessor);
        this.matSelect = matSelect;
    }
    setDisabled(disabled) {
        this.matSelect.disabled = disabled;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatSelectHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: MatSelect }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: MatSelectHasEnablePermissionDirective, isStandalone: true, selector: "mat-select[rxapHasEnablePermission]:not([formControl]):not([formControlName])", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatSelectHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'mat-select[rxapHasEnablePermission]:not([formControl]):not([formControlName])',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: i2$3.MatSelect, decorators: [{
                    type: Inject,
                    args: [MatSelect]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class MatSlideToggleHasEnablePermissionDirective extends HasEnablePermission {
    constructor(authorization, cdr, matSlideToggle, scope, valueAccessor = null) {
        super(authorization, cdr, scope, valueAccessor);
        this.matSlideToggle = matSlideToggle;
    }
    setDisabled(disabled) {
        this.matSlideToggle.disabled = disabled;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatSlideToggleHasEnablePermissionDirective, deps: [{ token: AuthorizationService }, { token: ChangeDetectorRef }, { token: MatSlideToggle }, { token: RXAP_AUTHORIZATION_SCOPE, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: MatSlideToggleHasEnablePermissionDirective, isStandalone: true, selector: "mat-slide-toggle[rxapHasEnablePermission]:not([formControl]):not([formControlName])", inputs: { identifier: ["rxapHasEnablePermission", "identifier"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: MatSlideToggleHasEnablePermissionDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'mat-slide-toggle[rxapHasEnablePermission]:not([formControl]):not([formControlName])',
                    standalone: true,
                }]
        }], ctorParameters: () => [{ type: AuthorizationService, decorators: [{
                    type: Inject,
                    args: [AuthorizationService]
                }] }, { type: i0.ChangeDetectorRef, decorators: [{
                    type: Inject,
                    args: [ChangeDetectorRef]
                }] }, { type: i2$4.MatSlideToggle, decorators: [{
                    type: Inject,
                    args: [MatSlideToggle]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [RXAP_AUTHORIZATION_SCOPE]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALUE_ACCESSOR]
                }] }], propDecorators: { identifier: [{
                type: Input,
                args: ['rxapHasEnablePermission']
            }] } });

class HasPermissionModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasPermissionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.1", ngImport: i0, type: HasPermissionModule, imports: [MatButtonHasEnablePermissionDirective,
            MatInputHasEnablePermissionDirective,
            MatSelectHasEnablePermissionDirective,
            MatCheckboxHasEnablePermissionDirective,
            MatSlideToggleHasEnablePermissionDirective,
            FormControlHasEnablePermissionDirective,
            IfHasPermissionDirective,
            HasWritePermissionDirective], exports: [MatButtonHasEnablePermissionDirective,
            MatInputHasEnablePermissionDirective,
            MatSelectHasEnablePermissionDirective,
            MatCheckboxHasEnablePermissionDirective,
            MatSlideToggleHasEnablePermissionDirective,
            FormControlHasEnablePermissionDirective,
            IfHasPermissionDirective,
            HasWritePermissionDirective] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasPermissionModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: HasPermissionModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        MatButtonHasEnablePermissionDirective,
                        MatInputHasEnablePermissionDirective,
                        MatSelectHasEnablePermissionDirective,
                        MatCheckboxHasEnablePermissionDirective,
                        MatSlideToggleHasEnablePermissionDirective,
                        FormControlHasEnablePermissionDirective,
                        IfHasPermissionDirective,
                        HasWritePermissionDirective,
                    ],
                    exports: [
                        MatButtonHasEnablePermissionDirective,
                        MatInputHasEnablePermissionDirective,
                        MatSelectHasEnablePermissionDirective,
                        MatCheckboxHasEnablePermissionDirective,
                        MatSlideToggleHasEnablePermissionDirective,
                        FormControlHasEnablePermissionDirective,
                        IfHasPermissionDirective,
                        HasWritePermissionDirective,
                    ],
                }]
        }] });

// region 
// endregion

/**
 * Generated bundle index. Do not edit.
 */

export { AuthorizationService, FormControlHasEnablePermissionDirective, HasEnablePermission, HasPermissionModule, HasWritePermissionDirective, IfHasPermissionDirective, MatButtonHasEnablePermissionDirective, MatCheckboxHasEnablePermissionDirective, MatInputHasEnablePermissionDirective, MatSelectHasEnablePermissionDirective, MatSlideToggleHasEnablePermissionDirective, RXAP_AUTHORIZATION_SCOPE, RXAP_DISABLE_AUTHORIZATION, RXAP_GET_SYSTEM_ROLES_METHOD };
//# sourceMappingURL=rxap-authorization.mjs.map
