import { __esDecorate, __runInitializers } from "tslib";
import { AccessRule } from './AccessRule.js';
import { observed } from '../../decorators/observed.js';
/**
 * The action is allowed if the authenticated user's ID matches a specific property on the resource.
 * This is typically used to restrict access to resources owned by the user.
 * For example, a user can only access their own profile or documents.
 */
let MatchResourceOwnerAccessRule = (() => {
    let _classSuper = AccessRule;
    let _property_decorators;
    let _property_initializers = [];
    let _property_extraInitializers = [];
    let _target_decorators;
    let _target_initializers = [];
    let _target_extraInitializers = [];
    return class MatchResourceOwnerAccessRule extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _property_decorators = [observed()];
            _target_decorators = [observed()];
            __esDecorate(this, null, _property_decorators, { kind: "accessor", name: "property", static: false, private: false, access: { has: obj => "property" in obj, get: obj => obj.property, set: (obj, value) => { obj.property = value; } }, metadata: _metadata }, _property_initializers, _property_extraInitializers);
            __esDecorate(this, null, _target_decorators, { kind: "accessor", name: "target", static: false, private: false, access: { has: obj => "target" in obj, get: obj => obj.target, set: (obj, value) => { obj.target = value; } }, metadata: _metadata }, _target_initializers, _target_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        type;
        #property_accessor_storage = __runInitializers(this, _property_initializers, void 0);
        get property() { return this.#property_accessor_storage; }
        set property(value) { this.#property_accessor_storage = value; }
        #target_accessor_storage = (__runInitializers(this, _property_extraInitializers), __runInitializers(this, _target_initializers, void 0));
        get target() { return this.#target_accessor_storage; }
        set target(value) { this.#target_accessor_storage = value; }
        constructor(state = {}) {
            super(state);
            __runInitializers(this, _target_extraInitializers);
            this.type = 'matchResourceOwner';
            this.property = state.property;
            this.target = state.target ?? 'property';
        }
        toJSON() {
            const json = {
                ...super.toJSON(),
                target: this.target,
            };
            if (this.property) {
                json.property = this.property;
            }
            return json;
        }
    };
})();
export { MatchResourceOwnerAccessRule };
//# sourceMappingURL=MatchResourceOwner.js.map