/*
 * Copyright 2015-2024 Ritense BV, the Netherlands.
 *
 * Licensed under EUPL, Version 1.2 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { Component, HostBinding, ViewChild, ViewContainerRef, ViewEncapsulation, } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SkeletonModule } from 'carbon-components-angular';
import { map, startWith, switchMap } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@angular/router";
import * as i2 from "../../services";
import * as i3 from "@angular/common";
export class PageActionsComponent {
    constructor(router, activatedRoute, pageTitleService, pageHeaderService, pageSubtitleService) {
        this.router = router;
        this.activatedRoute = activatedRoute;
        this.pageTitleService = pageTitleService;
        this.pageHeaderService = pageHeaderService;
        this.pageSubtitleService = pageSubtitleService;
        this.class = 'valtimo-page-actions';
        this.hasCustomPageSubtitle$ = this.router.events.pipe(startWith(this.router), switchMap(() => this.activatedRoute.firstChild.data), map(data => !!data?.customPageSubtitle));
        this.hasPageActions$ = this.pageTitleService.hasPageActions$;
        this.pageActionsFullWidth$ = this.pageTitleService.pageActionsFullWidth$;
        this.compactMode$ = this.pageHeaderService.compactMode$;
    }
    ngAfterViewInit() {
        this.pageTitleService.setPageActionsViewContainerRef(this._pageActionsVcr);
        this.pageSubtitleService.setActionsViewContainerRef(this._subtitleVcr);
        this.openPageActionsMutationObserver();
    }
    ngOnDestroy() {
        this._pageActionsObserver?.disconnect();
    }
    openPageActionsMutationObserver() {
        if (!this._pageActions)
            return;
        this._pageActionsObserver = new MutationObserver(mutations => {
            const firstMutation = mutations[0];
            const target = firstMutation?.target;
            const children = target?.children;
            const childrenArray = (children && Array.from(children)) || [];
            this.pageHeaderService.setPageActionsHasContent(childrenArray.length > 0);
        });
        this._pageActionsObserver.observe(this._pageActions.nativeElement, { childList: true });
        this.setInitialPageActionsHasChildren();
    }
    setInitialPageActionsHasChildren() {
        const children = this._pageActions.nativeElement.children;
        const childrenArray = (children && Array.from(children)) || [];
        this.pageHeaderService.setPageActionsHasContent(childrenArray.length > 0);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PageActionsComponent, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }, { token: i2.PageTitleService }, { token: i2.PageHeaderService }, { token: i2.PageSubtitleService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: PageActionsComponent, isStandalone: true, selector: "valtimo-page-actions", host: { properties: { "class": "this.class" } }, viewQueries: [{ propertyName: "_pageActionsVcr", first: true, predicate: ["pageActionsVcr"], descendants: true, read: ViewContainerRef, static: true }, { propertyName: "_pageActions", first: true, predicate: ["pageActions"], descendants: true }, { propertyName: "_subtitleVcr", first: true, predicate: ["subtitleVcr"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<!--\n  ~ Copyright 2015-2024 Ritense BV, the Netherlands.\n  ~\n  ~ Licensed under EUPL, Version 1.2 (the \"License\");\n  ~ you may not use this file except in compliance with the License.\n  ~ You may obtain a copy of the License at\n  ~\n  ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n  ~\n  ~ Unless required by applicable law or agreed to in writing, software\n  ~ distributed under the License is distributed on an \"AS IS\" basis,\n  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~ See the License for the specific language governing permissions and\n  ~ limitations under the License.\n  -->\n\n<div\n  class=\"page-actions-container\"\n  [ngClass]=\"{\n    '--compact': compactMode$ | async,\n  }\"\n>\n  <ng-container #subtitleVcr></ng-container>\n\n  <div\n    #pageActions\n    [ngClass]=\"{\n      'page-actions--visible': hasPageActions$ | async,\n      'page-actions--full-width': (pageActionsFullWidth$ | async),\n      'page-actions--compact': (hasPageActions$ | async) && (compactMode$ | async),\n    }\"\n    class=\"page-actions\"\n  >\n    <ng-container #pageActionsVcr></ng-container>\n  </div>\n</div>\n", styles: [".valtimo-page-actions{width:100%}.page-actions-container{display:flex}.page-actions-container.--compact{align-items:flex-start}.page-actions-container .page-actions--visible{margin-left:auto;padding-left:32px}.page-actions-container .page-actions--compact{padding-left:0}.page-actions-container .page-actions--full-width{width:100%}.page-actions-container .subtitle-skeleton-container .cds--skeleton__placeholder{height:18px;margin-bottom:8px;width:200px;margin-left:16px}.page-actions-container .subtitle-skeleton-container.--compact .cds--skeleton__placeholder{height:18px;width:60px;margin:0}.page-actions-container .page-subtitle{margin-left:16px;padding-bottom:4px;color:var(--cds-text-helper, #6f6f6f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px;line-height:18px}.page-actions-container .page-subtitle b{font-weight:bolder}.page-actions-container .page-subtitle.--compact{padding-bottom:0;margin-left:0}\n/*!\n * Copyright 2015-2024 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { kind: "ngmodule", type: SkeletonModule }], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PageActionsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'valtimo-page-actions', standalone: true, imports: [CommonModule, SkeletonModule], encapsulation: ViewEncapsulation.None, template: "<!--\n  ~ Copyright 2015-2024 Ritense BV, the Netherlands.\n  ~\n  ~ Licensed under EUPL, Version 1.2 (the \"License\");\n  ~ you may not use this file except in compliance with the License.\n  ~ You may obtain a copy of the License at\n  ~\n  ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n  ~\n  ~ Unless required by applicable law or agreed to in writing, software\n  ~ distributed under the License is distributed on an \"AS IS\" basis,\n  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~ See the License for the specific language governing permissions and\n  ~ limitations under the License.\n  -->\n\n<div\n  class=\"page-actions-container\"\n  [ngClass]=\"{\n    '--compact': compactMode$ | async,\n  }\"\n>\n  <ng-container #subtitleVcr></ng-container>\n\n  <div\n    #pageActions\n    [ngClass]=\"{\n      'page-actions--visible': hasPageActions$ | async,\n      'page-actions--full-width': (pageActionsFullWidth$ | async),\n      'page-actions--compact': (hasPageActions$ | async) && (compactMode$ | async),\n    }\"\n    class=\"page-actions\"\n  >\n    <ng-container #pageActionsVcr></ng-container>\n  </div>\n</div>\n", styles: [".valtimo-page-actions{width:100%}.page-actions-container{display:flex}.page-actions-container.--compact{align-items:flex-start}.page-actions-container .page-actions--visible{margin-left:auto;padding-left:32px}.page-actions-container .page-actions--compact{padding-left:0}.page-actions-container .page-actions--full-width{width:100%}.page-actions-container .subtitle-skeleton-container .cds--skeleton__placeholder{height:18px;margin-bottom:8px;width:200px;margin-left:16px}.page-actions-container .subtitle-skeleton-container.--compact .cds--skeleton__placeholder{height:18px;width:60px;margin:0}.page-actions-container .page-subtitle{margin-left:16px;padding-bottom:4px;color:var(--cds-text-helper, #6f6f6f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px;line-height:18px}.page-actions-container .page-subtitle b{font-weight:bolder}.page-actions-container .page-subtitle.--compact{padding-bottom:0;margin-left:0}\n/*!\n * Copyright 2015-2024 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n"] }]
        }], ctorParameters: () => [{ type: i1.Router }, { type: i1.ActivatedRoute }, { type: i2.PageTitleService }, { type: i2.PageHeaderService }, { type: i2.PageSubtitleService }], propDecorators: { _pageActionsVcr: [{
                type: ViewChild,
                args: ['pageActionsVcr', { static: true, read: ViewContainerRef }]
            }], _pageActions: [{
                type: ViewChild,
                args: ['pageActions']
            }], _subtitleVcr: [{
                type: ViewChild,
                args: ['subtitleVcr', { static: true, read: ViewContainerRef }]
            }], class: [{
                type: HostBinding,
                args: ['class']
            }] } });
//# sourceMappingURL=data:application/json;base64, 