import * as i0 from '@angular/core';
import { Injectable, signal, Component, Input, EventEmitter, Output, Pipe, ChangeDetectionStrategy, LOCALE_ID, Inject, NgModule, CUSTOM_ELEMENTS_SCHEMA, Directive, ViewChild, inject, computed, HostBinding, HostListener, SecurityContext, createNgModule } from '@angular/core';
import * as i4 from 'common';
import { deepClone, emptyObject, isVoid, Button, isFalse, SelectionStatus, BaseComponentRegistry, ActionHandler, isEmptyString, isTrue, MessageTypes, BaseServiceRegistry, SortDirection, PageSelection, OverridableMap, EDITABLE_VIEW_MODES, BaseField, BaseTypeRegistry, LineActionEvent, isEditable, ready, ALL_VIEW_MODES, PaginationType } from 'common';
import { BehaviorSubject, of, merge, combineLatestWith, forkJoin, Subject, fromEvent, throwError, timer, combineLatest, Subscription, isObservable, from } from 'rxjs';
import { map, distinctUntilChanged, tap, shareReplay, first, take, debounceTime, filter, catchError, skip, finalize, startWith, takeWhile, debounce, concatAll, toArray, concatMap, takeUntil } from 'rxjs/operators';
import * as i1 from 'apollo-angular';
import { gql } from 'apollo-angular';
import * as i1$1 from '@angular/cdk/layout';
import { Breakpoints } from '@angular/cdk/layout';
import { isString, isEmpty, isNil, trimStart, trimEnd, isEqual, isNull, isObject, isArray, uniqBy, toInteger, merge as merge$1, isNumber, union, floor, toNumber } from 'lodash-es';
import * as i2 from '@angular/common';
import { formatNumber, formatDate, formatCurrency, CommonModule, DecimalPipe, DOCUMENT } from '@angular/common';
import * as i3 from 'angular-svg-icon';
import { AngularSvgIconModule } from 'angular-svg-icon';
import * as i3$1 from '@ng-bootstrap/ng-bootstrap';
import { NgbModule, NgbDropdownModule, NgbTooltipModule, NgbModalModule, NgbPopover, NgbDatepickerModule, NgbTimepickerModule, NgbDateParserFormatter, NgbDateAdapter, ModalDismissReasons, NgbAlertModule, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
import { DateTime, IANAZone } from 'luxon';
import get from 'lodash-es/get';
import partial from 'lodash-es/partial';
import * as i3$2 from '@swimlane/ngx-charts';
import { NgxChartsModule } from '@swimlane/ngx-charts';
import * as i3$3 from 'ng-dynamic-component';
import { DynamicModule } from 'ng-dynamic-component';
import * as i5 from '@angular/cdk/drag-drop';
import { moveItemInArray, transferArrayItem, DragDropModule } from '@angular/cdk/drag-drop';
import { multiply, divide, round } from 'mathjs';
import * as i1$2 from '@angular/router';
import { RouterModule, DefaultUrlSerializer, PRIMARY_OUTLET, RouterLink, NavigationEnd, UrlTree } from '@angular/router';
import { MutationObserverFactory } from '@angular/cdk/observers';
import { trigger, transition, animate, style, useAnimation } from '@angular/animations';
import * as i7 from 'primeng/api';
import { SharedModule } from 'primeng/api';
import * as i10 from 'primeng/multiselect';
import { MultiSelectModule } from 'primeng/multiselect';
import * as i5$1 from '@angular/forms';
import { FormsModule, ReactiveFormsModule, UntypedFormGroup, Validators, UntypedFormArray, UntypedFormControl, FormGroup, FormControl } from '@angular/forms';
import * as i5$2 from 'ngx-chips';
import { TagInputModule } from 'ngx-chips';
import * as i1$3 from '@angular/common/http';
import { HttpParams, HttpHeaders } from '@angular/common/http';
import * as i13 from 'primeng/dropdown';
import { DropdownModule } from 'primeng/dropdown';
import * as i14 from 'primeng/inputtext';
import { InputTextModule } from 'primeng/inputtext';
import * as i5$3 from '@tinymce/tinymce-angular';
import { TINYMCE_SCRIPT_SRC, EditorModule } from '@tinymce/tinymce-angular';
import isObjectLike from 'lodash-es/isObjectLike';
import set from 'lodash-es/set';
import { fadeIn, fadeOut, backInDown } from 'ng-animate';
import defaults from 'lodash-es/defaults';
import * as i7$1 from 'primeng/sidebar';
import { SidebarModule } from 'primeng/sidebar';
import * as i1$4 from '@angular/cdk/clipboard';
import * as i4$1 from '@angular/cdk/table';
import { CdkTableModule } from '@angular/cdk/table';
import * as i5$4 from '@angular/cdk/scrolling';
import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
import * as i1$5 from '@angular/platform-browser';
import { loadRemoteModule } from '@angular-architects/module-federation-runtime';

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CollectionGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Fetch data either from backend or cache
     *
     * @param {string} module to get from
     * @param {object} metadata with the fields to ask for
     *
     * @returns {object} Observable<ApolloQueryResult<any>>
     */
    fetchAll(module, metadata) {
        const fields = metadata.fields;
        const queryOptions = {
            query: gql `
                query ${module}{
                    ${module} {
                        edges {
                            node {
                                ${fields.join('\n')}
                            }
                        }
                    }
                }
            `
        };
        return this.apollo.query(queryOptions);
    }
    static { this.ɵfac = function CollectionGQL_Factory(t) { return new (t || CollectionGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CollectionGQL, factory: CollectionGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CollectionGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$n = {
    configs: {},
    loading: false
};
let internalState$a = deepClone(initialState$n);
let cache$$7 = null;
class SystemConfigStore {
    constructor(collectionGQL) {
        this.collectionGQL = collectionGQL;
        this.store = new BehaviorSubject(internalState$a);
        this.state$ = this.store.asObservable();
        this.resourceName = 'systemConfigs';
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
                'value',
                'items'
            ]
        };
        this.configs$ = this.state$.pipe(map(state => state.configs), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading));
    }
    /**
     * Public Api
     */
    /**
     * Get system config value by key
     *
     * @param {string} configKey of the config
     * @returns {{}|string} config value
     */
    getConfigValue(configKey) {
        if (!internalState$a.configs || !internalState$a.configs[configKey]) {
            return null;
        }
        if (internalState$a.configs[configKey].value !== null) {
            return internalState$a.configs[configKey].value;
        }
        return internalState$a.configs[configKey].items;
    }
    /**
     * Get ui config value by key
     *
     * @param {string} configKey of the ui config
     * @returns {{}|string} config value
     */
    getUi(configKey) {
        const ui = this.getConfigValue('ui') ?? {};
        return ui[configKey] ?? null;
    }
    getHomePage() {
        let defaultModule = 'home';
        const defaultModuleConfig = this.getConfigValue('default_module');
        if (defaultModuleConfig) {
            defaultModule = defaultModuleConfig;
        }
        return defaultModule;
    }
    /**
     * Clear state
     */
    clear() {
        cache$$7 = null;
        this.updateState(deepClone(initialState$n));
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Initial SystemConfigs load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @returns {Observable<{}>} observable
     */
    load() {
        this.updateState({ ...internalState$a, loading: true });
        return this.getSystemConfigs().pipe(tap(configs => {
            this.updateState({ ...internalState$a, configs, loading: false });
        }));
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$7 !== null;
    }
    /**
     * Set pre-loaded configs and cache
     */
    set(configs) {
        cache$$7 = of(configs).pipe(shareReplay(1));
        this.updateState({ ...internalState$a, configs, loading: false });
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {{}} state new state
     */
    updateState(state) {
        this.store.next(internalState$a = state);
    }
    /**
     * Get SystemConfigs cached Observable or call the backend
     *
     * @returns {Observable<{}>} observable
     */
    getSystemConfigs() {
        if (cache$$7 == null) {
            cache$$7 = this.fetch().pipe(shareReplay(1));
        }
        return cache$$7;
    }
    /**
     * Fetch the App strings from the backend
     *
     * @returns {Observable<{}>} observable
     */
    fetch() {
        return this.collectionGQL
            .fetchAll(this.resourceName, this.fieldsMetadata).pipe(map(({ data }) => {
            const configs = {};
            if (data.systemConfigs && data.systemConfigs.edges) {
                data.systemConfigs.edges.forEach((edge) => {
                    // eslint-disable-next-line no-underscore-dangle
                    configs[edge.node._id] = edge.node;
                });
            }
            return configs;
        }));
    }
    static { this.ɵfac = function SystemConfigStore_Factory(t) { return new (t || SystemConfigStore)(i0.ɵɵinject(CollectionGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SystemConfigStore, factory: SystemConfigStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SystemConfigStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: CollectionGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
var ScreenSize;
(function (ScreenSize) {
    ScreenSize["XSmall"] = "XSmall";
    ScreenSize["Small"] = "Small";
    ScreenSize["Medium"] = "Medium";
    ScreenSize["Large"] = "Large";
    ScreenSize["XLarge"] = "XLarge";
})(ScreenSize || (ScreenSize = {}));
class ScreenSizeObserverService {
    constructor(breakpointObserver) {
        this.breakpointObserver = breakpointObserver;
        this.screenSize = new BehaviorSubject(ScreenSize.Medium);
        this.screenSize$ = this.screenSize.asObservable();
        this.initScreenSizeObservable();
    }
    initScreenSizeObservable() {
        merge(this.breakpointObserver.observe([
            Breakpoints.XSmall,
        ]).pipe(map((result) => {
            if (result.matches) {
                return ScreenSize.XSmall;
            }
        })), this.breakpointObserver.observe([
            Breakpoints.Small,
        ]).pipe(map((result) => {
            if (result.matches) {
                return ScreenSize.Small;
            }
        })), this.breakpointObserver.observe([
            Breakpoints.Medium,
        ]).pipe(map((result) => {
            if (result.matches) {
                return ScreenSize.Medium;
            }
        })), this.breakpointObserver.observe([
            Breakpoints.Large,
        ]).pipe(map((result) => {
            if (result.matches) {
                return ScreenSize.Large;
            }
        })), this.breakpointObserver.observe([
            Breakpoints.XLarge,
        ]).pipe(map((result) => {
            if (result.matches) {
                return ScreenSize.XLarge;
            }
        }))).subscribe((value) => {
            if (value) {
                this.screenSize.next(value);
            }
        });
    }
    static { this.ɵfac = function ScreenSizeObserverService_Factory(t) { return new (t || ScreenSizeObserverService)(i0.ɵɵinject(i1$1.BreakpointObserver)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ScreenSizeObserverService, factory: ScreenSizeObserverService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ScreenSizeObserverService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$1.BreakpointObserver }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EntityGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Fetch data either from backend or cache
     *
     * @param {string} entity to get from
     * @param {string} id of the record
     * @param {object} metadata with the fields to ask for
     *
     * @returns {object}  Observable<ApolloQueryResult<any>>
     */
    fetch(entity, id, metadata) {
        const fields = metadata.fields;
        const queryOptions = {
            query: gql `
              query ${entity}($id: ID!) {
                ${entity}(id: $id) {
                  ${fields.join('\n')}
                }
              }
            `,
            variables: {
                id,
            },
        };
        return this.apollo.query(queryOptions);
    }
    static { this.ɵfac = function EntityGQL_Factory(t) { return new (t || EntityGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: EntityGQL, factory: EntityGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LocalStorageService {
    constructor() {
        this.storageKey = 'scrm-session-storage';
        this.stickyStorageKey = 'scrm-sticky-session-storage';
    }
    clear() {
        this.getLocalStorage().removeItem(this.storageKey);
        const sticky = this.getLocalStorage().getItem(this.stickyStorageKey);
        if (sticky) {
            this.getLocalStorage().setItem(this.storageKey, sticky);
        }
    }
    set(key, data, sticky = false) {
        this.store(this.storageKey, key, data);
        if (sticky) {
            this.store(this.stickyStorageKey, key, data);
        }
    }
    store(storageKey, key, data) {
        const storeJson = this.getLocalStorage().getItem(storageKey);
        let store = {};
        if (storeJson) {
            store = JSON.parse(storeJson);
        }
        store[key] = data;
        this.getLocalStorage().setItem(storageKey, JSON.stringify(store));
    }
    get(key) {
        const storeJson = this.getLocalStorage().getItem(this.storageKey);
        let store = {};
        if (storeJson) {
            store = JSON.parse(storeJson);
        }
        return store[key];
    }
    getLocalStorage() {
        return localStorage;
    }
    static { this.ɵfac = function LocalStorageService_Factory(t) { return new (t || LocalStorageService)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LocalStorageService, factory: LocalStorageService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LocalStorageService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EntityMutationGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Create record on the backend
     *
     * @param {string} graphqlEntityName to use
     * @param {string} entityName to use
     * @param {object} input values
     * @param {object} metadata with the fields to ask for
     *
     * @returns {object} Observable<any>
     */
    create(graphqlEntityName, entityName, input, metadata) {
        const fields = metadata.fields;
        const mutationOptions = {
            mutation: gql `
                mutation create${entityName}($input: create${entityName}Input!) {
                  create${entityName}(input: $input) {
                    ${graphqlEntityName} {
                      ${fields.join('\n')}
                    }
                    clientMutationId
                  }
                }
            `,
            variables: {
                input
            },
        };
        return this.apollo.mutate(mutationOptions);
    }
    static { this.ɵfac = function EntityMutationGQL_Factory(t) { return new (t || EntityMutationGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: EntityMutationGQL, factory: EntityMutationGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityMutationGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const blankProcess = {
    id: null,
    _id: null,
    status: null,
    async: null,
    type: null,
    options: null,
    messages: []
};
class ProcessService {
    constructor(recordMutationGQL) {
        this.recordMutationGQL = recordMutationGQL;
        this.graphqlName = 'process';
        this.coreName = 'Process';
        this.createFieldsMetadata = {
            fields: [
                '_id',
                'status',
                'async',
                'type',
                'messages',
                'data'
            ]
        };
    }
    /**
     * Public Api
     */
    /**
     * Submit and action/process request
     * Returns observable
     *
     * @param {string} type to create
     * @param {object} options to send
     * @returns {object} Observable<any>
     */
    submit(type, options) {
        return this.create(type, options);
    }
    /**
     * Internal API
     */
    /**
     * Create a process on the backend
     *
     * @param {string} type to create
     * @param {object} options to send
     * @returns {object} Observable<any>
     */
    create(type, options) {
        const input = {
            type,
            options
        };
        return this.recordMutationGQL.create(this.graphqlName, this.coreName, input, this.createFieldsMetadata)
            .pipe(map(({ data }) => {
            const process = { ...blankProcess };
            if (data.createProcess && data.createProcess.process) {
                return data.createProcess.process;
            }
            return process;
        }));
    }
    static { this.ɵfac = function ProcessService_Factory(t) { return new (t || ProcessService)(i0.ɵɵinject(EntityMutationGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ProcessService, factory: ProcessService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ProcessService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityMutationGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$m = {
    appStrings: {},
    appListStrings: {},
    modStrings: {},
    languageKey: 'en_us',
    loaded: {},
    hasChanged: false
};
let internalState$9 = deepClone(initialState$m);
const initialCache$1 = {
    appStrings: {},
    appListStrings: {},
    modStrings: {},
};
let loadedLanguages = {};
let cache$1 = deepClone(initialCache$1);
class LanguageStore {
    constructor(recordGQL, localStorage, processService, configs) {
        this.recordGQL = recordGQL;
        this.localStorage = localStorage;
        this.processService = processService;
        this.configs = configs;
        this.store = new BehaviorSubject(internalState$9);
        this.state$ = this.store.asObservable();
        this.config = {
            appStrings: {
                fetch: 'fetchAppStrings',
                resourceName: 'appStrings',
                metadata: {
                    fields: [
                        'id',
                        '_id',
                        'items'
                    ]
                }
            },
            appListStrings: {
                fetch: 'fetchAppListStrings',
                resourceName: 'appListStrings',
                metadata: {
                    fields: [
                        'id',
                        '_id',
                        'items'
                    ]
                }
            },
            modStrings: {
                fetch: 'fetchModStrings',
                resourceName: 'modStrings',
                metadata: {
                    fields: [
                        'id',
                        '_id',
                        'items'
                    ]
                }
            },
        };
        this.appStrings$ = this.state$.pipe(map(state => state.appStrings), distinctUntilChanged());
        this.appListStrings$ = this.state$.pipe(map(state => state.appListStrings), distinctUntilChanged());
        this.modStrings$ = this.state$.pipe(map(state => state.modStrings), distinctUntilChanged());
        this.languageKey$ = this.state$.pipe(map(state => state.languageKey), distinctUntilChanged());
        this.vm$ = this.appStrings$
            .pipe(combineLatestWith(this.appListStrings$, this.modStrings$, this.languageKey$), map(([appStrings, appListStrings, modStrings, languageKey]) => ({ appStrings, appListStrings, modStrings, languageKey })));
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        loadedLanguages = {};
        cache$1 = deepClone(initialCache$1);
        this.updateState(deepClone(initialState$m));
    }
    clearAuthBased() {
        const keysToClear = ['modStrings', 'appListStrings'];
        keysToClear.forEach(type => {
            if (loadedLanguages && loadedLanguages[type]) {
                delete loadedLanguages[type];
            }
        });
        cache$1.modStrings = {};
        cache$1.appListStrings = {};
    }
    /**
     * Update the language strings toe the given language
     *
     * @param {string} languageKey language key
     * @param {boolean} reload
     */
    changeLanguage(languageKey, reload = false) {
        const types = [];
        Object.keys(loadedLanguages).forEach(type => loadedLanguages[type] && types.push(type));
        internalState$9.hasChanged = true;
        return this.load(languageKey, types, reload).pipe(tap(() => {
            this.localStorage.set('selected_language', languageKey, true);
        }));
    }
    /**
     * Get All languageStrings label by key
     *
     * @returns {object} LanguageStrings
     */
    getLanguageStrings() {
        if (!internalState$9) {
            return null;
        }
        return {
            appStrings: internalState$9.appStrings,
            appListStrings: internalState$9.appListStrings,
            modStrings: internalState$9.modStrings,
            languageKey: internalState$9.languageKey
        };
    }
    /**
     * Get AppStrings label by key
     *
     * @param {string} labelKey to fetch
     * @returns {string} label
     */
    getAppString(labelKey) {
        if (!internalState$9.appStrings || !internalState$9.appStrings[labelKey]) {
            return null;
        }
        return internalState$9.appStrings[labelKey];
    }
    /**
     * Get AppListStrings label by key
     *
     * @param {string} labelKey to fetch
     * @returns {string|{}} app strings
     */
    getAppListString(labelKey) {
        if (!internalState$9.appListStrings || !internalState$9.appListStrings[labelKey]) {
            return null;
        }
        return internalState$9.appListStrings[labelKey];
    }
    /**
     * Get ModStrings label by key
     *
     * @param {string} labelKey to fetch
     * @returns {string|{}} mod strings
     */
    getModString(labelKey) {
        if (!internalState$9.modStrings || !internalState$9.modStrings[labelKey]) {
            return null;
        }
        return internalState$9.modStrings[labelKey];
    }
    /**
     * Get field label
     *
     * @param {string} labelKey to fetch
     * @param {string} module to use
     * @param {object} lang to use
     * @returns {string} label
     */
    getFieldLabel(labelKey, module = null, lang = null) {
        let languages = lang;
        if (!lang) {
            languages = this.getLanguageStrings();
        }
        if (!languages || !languages.modStrings || !labelKey) {
            return '';
        }
        let label = '';
        if (module) {
            label = languages.modStrings[module] && languages.modStrings[module][labelKey];
        }
        if (!label) {
            label = languages.appStrings && languages.appStrings[labelKey];
        }
        return label || '';
    }
    /**
     * Get list label
     *
     * @param {string} listKey to fetch
     * @param {string} labelKey to fetch
     * @returns {string} label
     */
    getListLabel(listKey, labelKey) {
        if (!listKey || !labelKey) {
            return '';
        }
        const listStrings = this.getAppListString(listKey);
        if (!listStrings) {
            return '';
        }
        return listStrings[labelKey] || '';
    }
    /**
     * Get all available string types
     *
     * @returns {string[]} string types
     */
    getAvailableStringsTypes() {
        return Object.keys(this.config);
    }
    /**
     * Returns whether the language has changed manually
     *
     * @returns {boolean} has changed
     */
    hasLanguageChanged() {
        return internalState$9.hasChanged;
    }
    /**
     * Returns the currently active language
     *
     * @returns {string} current language key
     */
    getCurrentLanguage() {
        const storedLanguage = this.localStorage.get('selected_language');
        if (storedLanguage) {
            return storedLanguage;
        }
        return internalState$9.languageKey ?? 'en_us';
    }
    /**
     * Returns the active language
     *
     * @returns {string} active language key
     */
    getActiveLanguage() {
        return internalState$9.languageKey ?? '';
    }
    /**
     * Returns the selected language
     *
     * @returns {string} selected language key
     */
    getSelectedLanguage() {
        return this.localStorage.get('selected_language') ?? '';
    }
    /**
     * Check if language is enabled
     * @param currentLanguage
     */
    isLanguageEnabled(currentLanguage) {
        if (!currentLanguage) {
            return false;
        }
        const languages = this.configs.getConfigValue('languages') ?? {};
        const disabled = this.getDisabledLanguages();
        const languageKeys = Object.keys(languages);
        if (!languageKeys.length) {
            return false;
        }
        return languageKeys.includes(currentLanguage) && !disabled.includes(currentLanguage);
    }
    /**
     * Get disabled languages
     */
    getDisabledLanguages() {
        const disabledConfig = this.configs.getConfigValue('disabled_languages') ?? '';
        if (!isString(disabledConfig) || disabledConfig === '') {
            return [];
        }
        return disabledConfig.replace(' ', '').split(',');
    }
    /**
     * Get enabled languages
     */
    getEnabledLanguages() {
        const languages = this.configs.getConfigValue('languages') ?? {};
        const disabled = this.getDisabledLanguages();
        const enabled = {};
        const enabledKeys = Object.keys(languages).filter(value => !disabled.includes(value));
        enabledKeys.forEach(key => {
            enabled[key] = languages[key];
        });
        return enabled;
    }
    /**
     * Get fist language in list
     * @private
     */
    getFirstLanguage() {
        const languages = this.configs.getConfigValue('languages') ?? {};
        const languageKeys = Object.keys(languages);
        return languageKeys.sort()[0] ?? '';
    }
    /**
     * Initial Language Strings Load for given language and types if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} languageKey to load
     * @param {string[]} types to load
     * @param {boolean} reload
     * @returns {object} Observable
     */
    load(languageKey, types, reload = false) {
        const streams$ = [];
        types.forEach(type => streams$.push(this.getStrings(languageKey, type, reload)));
        return forkJoin(streams$).pipe(first(), tap(result => {
            const stateUpdate = { ...internalState$9, languageKey };
            types.forEach((type, index) => {
                stateUpdate[type] = result[index];
                loadedLanguages[type] = true;
            });
            this.updateState(stateUpdate);
        }));
    }
    /**
     * Check if loaded
     */
    areAllCached() {
        let isCached = true;
        isCached = isCached && !emptyObject(cache$1?.appStrings ?? {});
        isCached = isCached && !emptyObject(cache$1?.appListStrings ?? {});
        isCached = isCached && !emptyObject(cache$1?.modStrings ?? {});
        return isCached;
    }
    /**
     * Set pre-loaded strings and cache
     */
    set(languageKey, languageStrings) {
        const stateUpdate = { ...internalState$9, languageKey };
        if (languageStrings.appStrings && !emptyObject(languageStrings.appStrings)) {
            cache$1['appStrings'][languageKey] = of(languageStrings.appStrings).pipe(shareReplay(1));
            stateUpdate['appStrings'] = languageStrings.appStrings;
            loadedLanguages['appStrings'] = true;
        }
        if (languageStrings.appListStrings && !emptyObject(languageStrings.appListStrings)) {
            cache$1['appListStrings'][languageKey] = of(languageStrings.appListStrings).pipe(shareReplay(1));
            stateUpdate['appListStrings'] = languageStrings.appListStrings;
            loadedLanguages['appListStrings'] = true;
        }
        if (languageStrings.modStrings && !emptyObject(languageStrings.modStrings)) {
            cache$1['modStrings'][languageKey] = of(languageStrings.modStrings).pipe(shareReplay(1));
            stateUpdate['modStrings'] = languageStrings.modStrings;
            loadedLanguages['modStrings'] = true;
        }
        this.updateState(stateUpdate);
    }
    /**
     * Set session language
     */
    setSessionLanguage() {
        const processType = 'set-session-language';
        const options = {
            language: internalState$9.languageKey
        };
        return this.processService.submit(processType, options).pipe(take(1));
    }
    /**
     * Set session language
     */
    setUserLanguage() {
        const processType = 'set-user-language';
        const options = {
            language: internalState$9.languageKey
        };
        return this.processService.submit(processType, options).pipe(take(1));
    }
    /**
     * Internal API
     */
    /**
     * Update internal state cache and emit from store...
     *
     * @param {{}} state to set
     */
    updateState(state) {
        this.store.next(internalState$9 = state);
    }
    /**
     * Get given $type of strings Observable from cache  or call the backend
     *
     * @param {string} language to load
     * @param {string} type load
     * @param {boolean} reload
     * @returns {object} Observable<any>
     */
    getStrings(language, type, reload = false) {
        const stringsCache = cache$1[type];
        const fetchMethod = this.config[type].fetch;
        if (stringsCache[language] && reload === false) {
            return stringsCache[language];
        }
        stringsCache[language] = this[fetchMethod](language).pipe(shareReplay(1));
        return stringsCache[language];
    }
    /**
     * Fetch the App strings from the backend
     *
     * @param {string} language to fetch
     * @returns {{}} Observable<{}>
     */
    fetchAppStrings(language) {
        const resourceName = this.config.appStrings.resourceName;
        const fields = this.config.appStrings.metadata;
        return this.recordGQL.fetch(resourceName, `/api/app-strings/${language}`, fields)
            .pipe(map(({ data }) => {
            let items = {};
            if (data.appStrings) {
                items = data.appStrings.items;
            }
            return items;
        }));
    }
    /**
     * Fetch the App list strings from the backend
     *
     * @param {string} language to fetch
     * @returns {{}} Observable<{}>
     */
    fetchAppListStrings(language) {
        const resourceName = this.config.appListStrings.resourceName;
        const fields = this.config.appListStrings.metadata;
        return this.recordGQL.fetch(resourceName, `/api/app-list-strings/${language}`, fields)
            .pipe(map(({ data }) => {
            let items = {};
            if (data.appListStrings) {
                items = data.appListStrings.items;
            }
            return items;
        }));
    }
    /**
     * Fetch the Mod strings from the backend
     *
     * @param {string} language to fetch
     * @returns {{}} Observable<{}>
     */
    fetchModStrings(language) {
        const resourceName = this.config.modStrings.resourceName;
        const fields = this.config.modStrings.metadata;
        return this.recordGQL.fetch(resourceName, `/api/mod-strings/${language}`, fields)
            .pipe(map(({ data }) => {
            let items = {};
            if (data.modStrings) {
                items = data.modStrings.items;
            }
            return items;
        }));
    }
    static { this.ɵfac = function LanguageStore_Factory(t) { return new (t || LanguageStore)(i0.ɵɵinject(EntityGQL), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(ProcessService), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LanguageStore, factory: LanguageStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LanguageStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityGQL }, { type: LocalStorageService }, { type: ProcessService }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadingBuffer {
    constructor(config, delayConfigKey = 'loading_display_delay') {
        this.config = config;
        this.delayConfigKey = delayConfigKey;
        this.loadingStore = new BehaviorSubject(false);
        this.loadingBufferStore = new BehaviorSubject(false);
        this.subs = [];
        this.buffered = false;
        this.loading$ = this.loadingStore.asObservable();
        const uiSettings = config.getConfigValue('ui') ?? {};
        const delay = parseInt(uiSettings[delayConfigKey] ?? '') ?? 1500;
        this.loadingBufferStore$ = this.loadingBufferStore.asObservable().pipe(debounceTime(delay));
        this.subs.push(this.loadingBufferStore$.subscribe((loading) => {
            if (!this.buffered) {
                return;
            }
            this.loadingStore.next(loading);
        }));
    }
    /**
     * Update loading status
     *
     * @param {boolean} loading status to set
     */
    updateLoading(loading) {
        if (loading === true) {
            this.buffered = true;
            this.loadingBufferStore.next(loading);
            return;
        }
        this.buffered = false;
        this.loadingStore.next(loading);
        this.loadingBufferStore.next(loading);
    }
    static { this.ɵfac = function LoadingBuffer_Factory(t) { i0.ɵɵinvalidFactory(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoadingBuffer, factory: LoadingBuffer.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadingBuffer, [{
        type: Injectable
    }], function () { return [{ type: SystemConfigStore }, { type: undefined }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadingBufferFactory {
    constructor(config) {
        this.config = config;
    }
    create(delayConfigKey = 'loading_display_delay') {
        return new LoadingBuffer(this.config, delayConfigKey);
    }
    static { this.ɵfac = function LoadingBufferFactory_Factory(t) { return new (t || LoadingBufferFactory)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoadingBufferFactory, factory: LoadingBufferFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadingBufferFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$l = {
    loading: false,
    initialAppLoading: true,
    module: null,
    view: null,
    loaded: false,
    routeUrl: null,
    preLoginUrl: null,
    currentUser: null,
    activeRequests: 0,
    prevRoutes: [],
    isSidebarVisible: false,
    activeNavbarDropdown: 0
};
let internalState$8 = deepClone(initialState$l);
class AppStateStore {
    constructor(loadingBufferFactory, configs) {
        this.loadingBufferFactory = loadingBufferFactory;
        this.configs = configs;
        this.store = new BehaviorSubject(internalState$8);
        this.state$ = this.store.asObservable();
        this.loadingQueue = {};
        this.subs = [];
        this.isTouchScreen = signal(false);
        this.loading$ = this.state$.pipe(map(state => state.loading), distinctUntilChanged());
        this.module$ = this.state$.pipe(map(state => state.module), distinctUntilChanged());
        this.view$ = this.state$.pipe(map(state => state.view), distinctUntilChanged());
        this.initialAppLoading$ = this.state$.pipe(map(state => state.initialAppLoading), distinctUntilChanged());
        this.activeRequests$ = this.state$.pipe(map(state => state.activeRequests), distinctUntilChanged());
        this.isSidebarVisible$ = this.state$.pipe(map(state => state.isSidebarVisible), distinctUntilChanged());
        this.activeNavbarDropdown$ = this.state$.pipe(map(state => state.activeNavbarDropdown), distinctUntilChanged());
        this.vm$ = this.loading$.pipe(combineLatestWith(this.module$, this.view$, this.initialAppLoading$), map(([loading, module, view, initialAppLoading]) => ({
            loading,
            module,
            view,
            loaded: internalState$8.loaded,
            initialAppLoading,
            isSidebarVisible: internalState$8.isSidebarVisible,
            activeNavbarDropdown: internalState$8.activeNavbarDropdown
        })));
        if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
            this.isTouchScreen.set(true);
        }
        else {
            this.isTouchScreen.set(false);
        }
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        this.loadingQueue = {};
        this.updateState(deepClone(initialState$l));
        this.subs.forEach(sub => sub.unsubscribe());
    }
    clearAuthBased() {
    }
    init() {
        this.initLoadingBuffer();
    }
    /**
     * Check if is logged in
     */
    isLoggedIn() {
        return !!(internalState$8.currentUser ?? false);
    }
    /**
     * Get current user
     */
    getCurrentUser() {
        return internalState$8.currentUser;
    }
    /**
     * Set current user
     * @param user
     */
    setCurrentUser(user) {
        if (!isVoid(user)) {
            this.onLogin();
        }
        else {
            this.onLogout();
        }
        this.updateState({ ...internalState$8, currentUser: user });
    }
    /**
     * On login handlers
     * @protected
     */
    onLogin() {
    }
    /**
     * On logout handlers
     * @protected
     */
    onLogout() {
        this.updateState({ ...internalState$8, preLoginUrl: null });
    }
    /**
     * Get number of active requests
     */
    getActiveRequests() {
        return internalState$8.activeRequests;
    }
    /**
     * Add active request to counter
     */
    addActiveRequest() {
        let activeRequests = internalState$8.activeRequests;
        if (isVoid(activeRequests)) {
            activeRequests = 0;
        }
        activeRequests++;
        this.updateState({ ...internalState$8, activeRequests });
    }
    /**
     * Remove active request to counter
     */
    removeActiveRequest() {
        let activeRequests = internalState$8.activeRequests;
        if (isVoid(activeRequests)) {
            activeRequests = 0;
        }
        else {
            activeRequests--;
        }
        if (activeRequests < 0) {
            activeRequests = 0;
        }
        this.updateState({ ...internalState$8, activeRequests });
    }
    /**
     * Update loading status for given key
     *
     * @param {string} key to update
     * @param {boolean} loading status to set
     * @param {boolean} delay
     */
    updateLoading(key, loading, delay = true) {
        this.initLoadingBuffer();
        if (loading === true) {
            this.addToLoadingQueue(key);
            this.loadingBuffer.updateLoading(loading);
            if (!delay) {
                this.updateState({ ...internalState$8, loading });
            }
            return;
        }
        this.removeFromLoadingQueue(key);
        if (this.hasActiveLoading()) {
            this.loadingBuffer.updateLoading(loading);
            this.updateState({ ...internalState$8, loading });
        }
    }
    /**
     * Update loading status for given key
     *
     * @param {boolean} initialAppLoading status to set
     */
    updateInitialAppLoading(initialAppLoading) {
        this.updateState({ ...internalState$8, initialAppLoading });
    }
    /**
     * Has app been initially loaded
     *
     * @returns {boolean} is loaded
     */
    isLoaded() {
        return internalState$8.loaded;
    }
    /**
     * Set initial app load status
     *
     * @param {string} loaded flag
     */
    setLoaded(loaded) {
        this.updateState({ ...internalState$8, loaded });
    }
    /**
     * Set current module
     *
     * @param {string} module to set as current module
     */
    setModule(module) {
        this.updateState({ ...internalState$8, module });
    }
    /**
     * Get the current module
     *
     * @returns {string} current view
     */
    getModule() {
        return internalState$8?.module ?? '';
    }
    /**
     * Set current View
     *
     * @param {string} view to set as current view
     */
    setView(view) {
        this.updateState({ ...internalState$8, view });
    }
    /**
     * Get the current view
     *
     * @returns {string} current view
     */
    getView() {
        return internalState$8.view;
    }
    /**
     * Set route url
     *
     * @param {string} routeUrl to set
     */
    setRouteUrl(routeUrl) {
        this.updateState({ ...internalState$8, routeUrl });
    }
    /**
     * Get the route ulr
     *
     * @returns {string} current route url
     */
    getRouteUrl() {
        return internalState$8.routeUrl;
    }
    /**
     * set pre login url
     *
     * @param preLoginUrl
     */
    setPreLoginUrl(preLoginUrl) {
        this.updateState({ ...internalState$8, preLoginUrl });
    }
    /**
     * get pre login url
     *
     * @returns string
     */
    getPreLoginUrl() {
        return internalState$8.preLoginUrl ?? '';
    }
    /**
     * Internal API
     */
    /**
     * Init loading buffer
     * @protected
     */
    initLoadingBuffer() {
        if (!this.loadingBuffer) {
            this.loadingBuffer = this.loadingBufferFactory.create();
            this.subs.push(this.loadingBuffer.loading$.subscribe((loading) => {
                this.updateState({ ...internalState$8, loading });
            }));
        }
    }
    /**
     *  Check if there are still active loadings
     *
     *  @returns {boolean} active loading
     */
    hasActiveLoading() {
        return Object.keys(this.loadingQueue).length < 1;
    }
    /**
     * Remove key from loading queue
     *
     * @param {string} key to remove
     */
    removeFromLoadingQueue(key) {
        if (this.loadingQueue[key]) {
            delete this.loadingQueue[key];
        }
    }
    /**
     * Add key to loading queue
     *
     * @param {string} key to add
     */
    addToLoadingQueue(key) {
        this.loadingQueue[key] = true;
    }
    /**
     * Update the state
     *
     * @param {{}} state app state
     */
    updateState(state) {
        this.store.next(internalState$8 = state);
    }
    toggleSidebar() {
        this.updateState({ ...internalState$8, isSidebarVisible: !internalState$8.isSidebarVisible });
    }
    closeSidebar() {
        this.updateState({ ...internalState$8, isSidebarVisible: false });
    }
    getLatestPrevRoute() {
        return internalState$8.prevRoutes[internalState$8.prevRoutes.length - 2];
    }
    getPrevRoutes() {
        return internalState$8.prevRoutes;
    }
    addToPrevRoute(route) {
        const prevRoutes = this.getPrevRoutes();
        if (prevRoutes.length > 0 && prevRoutes[prevRoutes.length - 1] === route) {
            return;
        }
        prevRoutes.push(route);
        this.updateState({ ...internalState$8 });
    }
    removeLatestPrevRoute() {
        const prevRoutes = this.getPrevRoutes();
        const newArr = prevRoutes.slice(0, prevRoutes.length - 1);
        this.updateState({ ...internalState$8, prevRoutes: newArr });
    }
    removeAllPrevRoutes() {
        this.updateState({ ...internalState$8, prevRoutes: [] });
    }
    setActiveDropdown(key) {
        this.updateState({ ...internalState$8, activeNavbarDropdown: key });
    }
    getActiveDropdown() {
        return internalState$8.activeNavbarDropdown;
    }
    resetActiveDropdown() {
        this.updateState({ ...internalState$8, activeNavbarDropdown: 0 });
    }
    static { this.ɵfac = function AppStateStore_Factory(t) { return new (t || AppStateStore)(i0.ɵɵinject(LoadingBufferFactory), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppStateStore, factory: AppStateStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppStateStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LoadingBufferFactory }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$k = {
    theme: null,
    images: {}
};
let internalState$7 = deepClone(initialState$k);
let cachedTheme = null;
let cache$$6 = null;
class ThemeImagesStore {
    constructor(recordGQL, appStateStore, iconRegistry) {
        this.recordGQL = recordGQL;
        this.appStateStore = appStateStore;
        this.iconRegistry = iconRegistry;
        this.store = new BehaviorSubject(internalState$7);
        this.state$ = this.store.asObservable();
        this.resourceName = 'themeImages';
        this.frontendName = 'theme-images';
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
                'items'
            ]
        };
        this.images$ = this.state$.pipe(map(state => state.images), distinctUntilChanged());
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        cachedTheme = null;
        cache$$6 = null;
        this.updateState(deepClone(initialState$k));
    }
    clearAuthBased() {
    }
    /**
     * Change the current theme
     *
     * @param {string} theme to set
     */
    changeTheme(theme) {
        this.appStateStore.updateLoading('change-theme', true);
        this.load(theme).pipe(tap(() => this.appStateStore.updateLoading('change-theme', false))).subscribe();
    }
    /**
     * Returns the currently active image theme
     *
     * @returns {string} the theme
     */
    getTheme() {
        return internalState$7.theme;
    }
    /**
     * Initial ThemeImages load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} theme to load
     * @returns {object} Observable<any>
     */
    load(theme) {
        return this.getThemeImages(theme).pipe(tap(images => {
            this.updateState({ ...internalState$7, images, theme });
        }));
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$6 !== null;
    }
    /**
     * Set pre-loaded theme images and cache
     */
    set(theme, images) {
        cachedTheme = theme;
        this.registerSvgs(images);
        cache$$6 = of(images).pipe(shareReplay(1));
        this.updateState({ ...internalState$7, images });
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState$7 = state);
    }
    /**
     * Get theme images cached Observable or call the backend
     *
     * @param {string} theme to retrieve
     * @returns {object} Observable<any>
     */
    getThemeImages(theme) {
        if (cachedTheme !== theme || cache$$6 === null) {
            cachedTheme = theme;
            cache$$6 = this.fetch(theme).pipe(shareReplay(1));
        }
        return cache$$6;
    }
    registerSvgs(images) {
        Object.keys(images).forEach(key => {
            const image = images[key];
            const content = image['content'] ?? '';
            const name = image['name'] ?? '';
            if (content === '' || name === '') {
                return;
            }
            this.iconRegistry.addSvg(name, content);
        });
    }
    /**
     * Fetch the theme images from the backend
     *
     * @param {string} theme to load
     * @returns {object} Observable<any>
     */
    fetch(theme) {
        return this.recordGQL
            .fetch(this.resourceName, `/api/${this.frontendName}/${theme}`, this.fieldsMetadata)
            .pipe(map(({ data }) => {
            let images = {};
            if (data && data.themeImages) {
                images = data.themeImages.items;
            }
            if (!emptyObject(images)) {
                const parsedImages = {};
                this.registerSvgs(images);
                Object.keys(images).forEach(key => {
                    const { content, ...image } = images[key] ?? {};
                    parsedImages[key] = image;
                });
                return parsedImages;
            }
            return images;
        }));
    }
    static { this.ɵfac = function ThemeImagesStore_Factory(t) { return new (t || ThemeImagesStore)(i0.ɵɵinject(EntityGQL), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(i3.SvgIconRegistryService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ThemeImagesStore, factory: ThemeImagesStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ThemeImagesStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityGQL }, { type: AppStateStore }, { type: i3.SvgIconRegistryService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ImageComponent_ng_container_0_svg_icon_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "svg-icon", 3);
} if (rf & 2) {
    const img_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵclassMap(ctx_r2.wrapperClass);
    i0.ɵɵpropertyInterpolate("name", img_r1.name);
    i0.ɵɵproperty("svgClass", ctx_r2.klass || "")("title", ctx_r2.title || "");
} }
function ImageComponent_ng_container_0_img_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "img", 4);
} if (rf & 2) {
    const img_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵclassMap(ctx_r3.klass);
    i0.ɵɵpropertyInterpolate("src", img_r1.path, i0.ɵɵsanitizeUrl);
    i0.ɵɵproperty("title", ctx_r3.title || "");
} }
function ImageComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ImageComponent_ng_container_0_svg_icon_1_Template, 1, 6, "svg-icon", 1);
    i0.ɵɵtemplate(2, ImageComponent_ng_container_0_img_2_Template, 1, 5, "img", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const img_r1 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", img_r1.type === "svg");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", img_r1.type !== "svg");
} }
class ImageComponent {
    constructor(themeImagesStore) {
        this.themeImagesStore = themeImagesStore;
        this.klass = '';
        this.title = '';
        this.wrapperClass = 'sicon';
        this.images$ = this.themeImagesStore.images$;
        this.imageSig = signal({});
        this.subs = [];
    }
    ngOnInit() {
        this.subs = [];
        this.subs.push(this.images$.pipe(filter(img => img !== null), map((images) => ({ images })), tap(data => this.getImage(data, this.image))).subscribe());
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
    }
    /**
     * Get image from current view model and log if not existent
     *
     * @param vm
     * @param image name
     * @returns ThemeImage
     */
    getImage(vm, image) {
        if (!vm || !vm.images || Object.keys(vm.images).length < 1) {
            return null;
        }
        this.imageSig.update(() => vm.images[image]);
        if (!this.imageSig()) {
            console.warn(`Image with name '${image}' not found`);
        }
    }
    static { this.ɵfac = function ImageComponent_Factory(t) { return new (t || ImageComponent)(i0.ɵɵdirectiveInject(ThemeImagesStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ImageComponent, selectors: [["scrm-image"]], inputs: { image: "image", klass: "klass", title: "title", wrapperClass: "wrapperClass" }, decls: 1, vars: 1, consts: [[4, "ngIf"], [3, "svgClass", "title", "class", "name", 4, "ngIf"], ["alt", "", 3, "src", "class", "title", 4, "ngIf"], [3, "svgClass", "title", "name"], ["alt", "", 3, "src", "title"]], template: function ImageComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ImageComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.imageSig());
        } }, dependencies: [i2.NgIf, i3.SvgIconComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImageComponent, [{
        type: Component,
        args: [{ selector: 'scrm-image', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"imageSig() as img\">\n\n    <svg-icon *ngIf=\"img.type === 'svg'\" [svgClass]=\"klass || ''\" [title]=\"title || ''\" class=\"{{wrapperClass}}\"\n              name=\"{{img.name}}\"></svg-icon>\n\n    <img *ngIf=\"img.type !=='svg'\" alt=\"\" src=\"{{img.path}}\" class=\"{{klass}}\" [title]=\"title || ''\">\n\n</ng-container>\n" }]
    }], function () { return [{ type: ThemeImagesStore }]; }, { image: [{
            type: Input
        }], klass: [{
            type: Input
        }], title: [{
            type: Input
        }], wrapperClass: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LabelComponent_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r2.language.getFieldLabel(ctx_r2.labelKey, ctx_r2.module), " ");
} }
function LabelComponent_ng_container_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.language.getListLabel(ctx_r3.listKey, ctx_r3.labelKey), " ");
} }
function LabelComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LabelComponent_ng_container_0_ng_container_1_Template, 2, 1, "ng-container", 0);
    i0.ɵɵtemplate(2, LabelComponent_ng_container_0_ng_container_2_Template, 2, 1, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.listKey && ctx_r0.labelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.listKey && ctx_r0.labelKey);
} }
class LabelComponent {
    constructor(language) {
        this.language = language;
        this.labelKey = '';
        this.module = null;
        this.listKey = null;
        this.languages$ = this.language.vm$;
    }
    static { this.ɵfac = function LabelComponent_Factory(t) { return new (t || LabelComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LabelComponent, selectors: [["scrm-label"]], inputs: { labelKey: "labelKey", module: "module", listKey: "listKey" }, decls: 2, vars: 3, consts: [[4, "ngIf"]], template: function LabelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LabelComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.languages$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LabelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-label', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(languages$ | async) as languages\">\n    <ng-container *ngIf=\"!listKey && labelKey\">\n        {{language.getFieldLabel(labelKey, module)}}\n    </ng-container>\n    <ng-container *ngIf=\"listKey && labelKey\">\n        {{language.getListLabel(listKey, labelKey)}}\n    </ng-container>\n</ng-container>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { labelKey: [{
            type: Input
        }], module: [{
            type: Input
        }], listKey: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ButtonComponent_scrm_image_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 4);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("image", ctx_r0.config.icon)("klass", ctx_r0.config.iconKlass || "")("title", ctx_r0.language.getFieldLabel(ctx_r0.config.titleKey || ""));
} }
function ButtonComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r1.config.label || "");
} }
function ButtonComponent_scrm_label_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-label", 5);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    let tmp_1_0;
    i0.ɵɵproperty("labelKey", ctx_r2.config.labelKey)("module", (tmp_1_0 = ctx_r2.config.labelModule) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "");
} }
const _c0$O = ["*"];
class ButtonComponent {
    constructor(language) {
        this.language = language;
        this.clickBuffer = new Subject();
        this.clickBuffer$ = this.clickBuffer.asObservable();
        this.subs = [];
    }
    ngOnInit() {
        const isToDebounce = this.config?.debounceClick ?? null;
        this.clickCallBack = this.config?.onClick ?? null;
        const clickDebounceTime = this.getDebounceTime();
        if (isToDebounce && this.clickCallBack) {
            this.subs.push(this.clickBuffer$.pipe(debounceTime(clickDebounceTime)).subscribe(value => {
                const input = value ?? null;
                this.clickCallBack(input);
            }));
        }
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    runClick(input) {
        const isToDebounce = this.config?.debounceClick ?? null;
        if (!this.clickCallBack) {
            return;
        }
        if (isToDebounce && this.clickCallBack) {
            this.clickBuffer.next(input ?? null);
            return;
        }
        this.clickCallBack(input ?? null);
    }
    /**
     * Get debounce time
     * @return number
     * @protected
     */
    getDebounceTime() {
        let clickDebounceTime = this.config?.clickDebounceTime ?? 625;
        if (!isFinite(clickDebounceTime)) {
            clickDebounceTime = 625;
        }
        return clickDebounceTime;
    }
    static { this.ɵfac = function ButtonComponent_Factory(t) { return new (t || ButtonComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ButtonComponent, selectors: [["scrm-button"]], inputs: { config: "config" }, ngContentSelectors: _c0$O, decls: 5, vars: 6, consts: [["type", "button", 3, "ngClass", "disabled", "title", "click"], [3, "image", "klass", "title", 4, "ngIf"], [4, "ngIf"], [3, "labelKey", "module", 4, "ngIf"], [3, "image", "klass", "title"], [3, "labelKey", "module"]], template: function ButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "button", 0);
            i0.ɵɵlistener("click", function ButtonComponent_Template_button_click_0_listener($event) { return ctx.runClick($event); });
            i0.ɵɵtemplate(1, ButtonComponent_scrm_image_1_Template, 1, 3, "scrm-image", 1);
            i0.ɵɵtemplate(2, ButtonComponent_ng_container_2_Template, 2, 1, "ng-container", 2);
            i0.ɵɵtemplate(3, ButtonComponent_scrm_label_3_Template, 1, 2, "scrm-label", 3);
            i0.ɵɵprojection(4);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("ngClass", ctx.config.klass)("disabled", (ctx.config == null ? null : ctx.config.disabled) || "")("title", ctx.language.getFieldLabel(ctx.config.titleKey) || (ctx.config == null ? null : ctx.config.title) || "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config.icon);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.config.labelKey);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config.labelKey);
        } }, dependencies: [i2.NgClass, i2.NgIf, ImageComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-button', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<button type=\"button\"\n        [ngClass]=\"config.klass\"\n        (click)=\"runClick($event)\"\n        [disabled]=\"config?.disabled || ''\"\n        [title]=\"(language.getFieldLabel(config.titleKey) || config?.title) || ''\">\n    <scrm-image *ngIf=\"config.icon\"\n                [image]=\"config.icon\"\n                [klass]=\"config.iconKlass || ''\"\n                [title]=\"language.getFieldLabel(config.titleKey || '')\"></scrm-image>\n    <ng-container *ngIf=\"!config.labelKey\">{{ config.label || '' }}</ng-container>\n    <scrm-label *ngIf=\"config.labelKey\" [labelKey]=\"config.labelKey\" [module]=\"config.labelModule ?? ''\"></scrm-label>\n    <ng-content></ng-content>\n</button>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DropdownSubmenuComponent_scrm_image_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 5);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("image", ctx_r0.item.icon);
} }
function DropdownSubmenuComponent_div_5_li_2_scrm_image_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 5);
} if (rf & 2) {
    const subItem_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("image", subItem_r3.icon);
} }
function DropdownSubmenuComponent_div_5_li_2_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 9)(1, "a", 10);
    i0.ɵɵlistener("click", function DropdownSubmenuComponent_div_5_li_2_Template_a_click_1_listener() { const restoredCtx = i0.ɵɵrestoreView(_r7); const subItem_r3 = restoredCtx.$implicit; const ctx_r6 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r6.click(subItem_r3)); });
    i0.ɵɵtemplate(2, DropdownSubmenuComponent_div_5_li_2_scrm_image_2_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const subItem_r3 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", subItem_r3 && subItem_r3.klass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", subItem_r3.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", subItem_r3 && subItem_r3.label, " ");
} }
function DropdownSubmenuComponent_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6)(1, "ul", 7);
    i0.ɵɵtemplate(2, DropdownSubmenuComponent_div_5_li_2_Template, 4, 3, "li", 8);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngbCollapse", ctx_r1.isCollapsed);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r1.item.items);
} }
const _c0$N = ["*"];
class DropdownSubmenuComponent {
    constructor() {
        this.itemClicked = new EventEmitter();
        this.isCollapsed = true;
    }
    ngOnInit() {
    }
    click(item) {
        if (item && item.onClick) {
            item.onClick();
        }
        this.itemClicked.emit(true);
    }
    static { this.ɵfac = function DropdownSubmenuComponent_Factory(t) { return new (t || DropdownSubmenuComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DropdownSubmenuComponent, selectors: [["scrm-dropdown-submenu"]], inputs: { item: "item" }, outputs: { itemClicked: "item-clicked" }, ngContentSelectors: _c0$N, decls: 8, vars: 3, consts: [[1, "dropdown-submenu-items-container"], [1, "dropdown-submenu-parent-button", "dropdown-item", "dropdown-toggle", 3, "click"], [3, "image", 4, "ngIf"], [3, "ngbCollapse", 4, "ngIf"], [1, "dropdown-submenu-extra"], [3, "image"], [3, "ngbCollapse"], [1, "dropdown-submenu", "pl-2", "mb-1"], ["class", "dropdown-submenu-item dropdown-item", 4, "ngFor", "ngForOf"], [1, "dropdown-submenu-item", "dropdown-item"], [1, "action-link", "dropdown-submenu-item-link", 3, "ngClass", "click"]], template: function DropdownSubmenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "div")(1, "div", 0)(2, "a", 1);
            i0.ɵɵlistener("click", function DropdownSubmenuComponent_Template_a_click_2_listener() { return ctx.isCollapsed = !ctx.isCollapsed; });
            i0.ɵɵtemplate(3, DropdownSubmenuComponent_scrm_image_3_Template, 1, 1, "scrm-image", 2);
            i0.ɵɵtext(4);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(5, DropdownSubmenuComponent_div_5_Template, 3, 2, "div", 3);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 4);
            i0.ɵɵprojection(7);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.item && ctx.item.icon);
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate1(" ", ctx.item && ctx.item.label, " ");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.item && ctx.item.items.length);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, ImageComponent, i3$1.NgbCollapse], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownSubmenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dropdown-submenu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div>\n    <div class=\"dropdown-submenu-items-container\">\n        <a (click)=\"isCollapsed = !isCollapsed\"\n           class=\"dropdown-submenu-parent-button dropdown-item dropdown-toggle\"\n        >\n            <scrm-image *ngIf=\"item && item.icon\" [image]=\"item.icon\"></scrm-image>\n            {{item && item.label}}\n        </a>\n        <div *ngIf=\"item && item.items.length\" [ngbCollapse]=\"isCollapsed\">\n            <ul class=\"dropdown-submenu pl-2 mb-1\">\n\n                <li *ngFor=\"let subItem of item.items\" class=\"dropdown-submenu-item dropdown-item\">\n\n                    <a class=\"action-link dropdown-submenu-item-link\"\n                       [ngClass]=\"subItem && subItem.klass\"\n                       (click)=\"click(subItem)\">\n                        <scrm-image *ngIf=\"subItem.icon\" [image]=\"subItem.icon\"></scrm-image>\n                        {{subItem && subItem.label}}\n                    </a>\n                </li>\n            </ul>\n        </div>\n    </div>\n    <div class=\"dropdown-submenu-extra\">\n        <ng-content></ng-content>\n    </div>\n</div>\n" }]
    }], function () { return []; }, { item: [{
            type: Input
        }], itemClicked: [{
            type: Output,
            args: ['item-clicked']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TruncatePipe {
    transform(value, limit) {
        return value.length <= limit
            ? value
            : value.slice(0, limit) + '...';
    }
    static { this.ɵfac = function TruncatePipe_Factory(t) { return new (t || TruncatePipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "truncate", type: TruncatePipe, pure: true, standalone: true }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TruncatePipe, [{
        type: Pipe,
        args: [{
                name: 'truncate',
                standalone: true
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DropdownButtonComponent_scrm_image_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 7);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("image", ctx_r1.config.icon)("klass", ctx_r1.config.iconKlass || "");
} }
function DropdownButtonComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "truncate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r2.config.label, ctx_r2.charSize.maxLength), " ");
} }
function DropdownButtonComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 8);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r3.config.labelKey);
} }
function DropdownButtonComponent_ng_container_7_div_1_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
const _c0$M = function (a0) { return { item: a0 }; };
function DropdownButtonComponent_ng_container_7_div_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_container_7_div_1_ng_container_3_ng_container_1_Template, 1, 0, "ng-container", 13);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r13 = ctx.$implicit;
    i0.ɵɵnextContext(3);
    const _r6 = i0.ɵɵreference(10);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r6)("ngTemplateOutletContext", i0.ɵɵpureFunction1(2, _c0$M, item_r13));
} }
function DropdownButtonComponent_ng_container_7_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "div", 11);
    i0.ɵɵelement(2, "scrm-label", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, DropdownButtonComponent_ng_container_7_div_1_ng_container_3_Template, 2, 4, "ng-container", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const section_r9 = ctx.$implicit;
    const isLast_r10 = ctx.last;
    const isFirst_r11 = ctx.first;
    let tmp_3_0;
    let tmp_4_0;
    i0.ɵɵclassProp("section-split", !isFirst_r11)("last-section", isLast_r10)("first-section", isFirst_r11);
    i0.ɵɵproperty("ngClass", (tmp_3_0 = section_r9.klass) !== null && tmp_3_0 !== undefined ? tmp_3_0 : "");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", (tmp_4_0 = (tmp_4_0 = section_r9.labelKey) !== null && tmp_4_0 !== undefined ? tmp_4_0 : section_r9.label) !== null && tmp_4_0 !== undefined ? tmp_4_0 : "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", section_r9.items);
} }
function DropdownButtonComponent_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_container_7_div_1_Template, 4, 9, "div", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r4.sections);
} }
function DropdownButtonComponent_ng_container_8_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function DropdownButtonComponent_ng_container_8_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_container_8_ng_container_1_ng_container_1_Template, 1, 0, "ng-container", 13);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r17 = ctx.$implicit;
    i0.ɵɵnextContext(2);
    const _r6 = i0.ɵɵreference(10);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r6)("ngTemplateOutletContext", i0.ɵɵpureFunction1(2, _c0$M, item_r17));
} }
function DropdownButtonComponent_ng_container_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_container_8_ng_container_1_Template, 2, 4, "ng-container", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r5.config.items);
} }
function DropdownButtonComponent_ng_template_9_ng_container_0_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "scrm-image", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext(2).item;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("image", item_r19.icon)("klass", item_r19.iconKlass || "");
} }
function DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext(2).item;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", item_r19.label, " ");
} }
function DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_6_scrm_label_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-label", 18);
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext(3).item;
    let tmp_1_0;
    i0.ɵɵproperty("labelKey", item_r19.labelKey)("module", (tmp_1_0 = item_r19.labelModule) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "");
} }
function DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_6_scrm_label_1_Template, 1, 2, "scrm-label", 17);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext(2).item;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r19 && item_r19.labelKey);
} }
function DropdownButtonComponent_ng_template_9_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r32 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 14);
    i0.ɵɵlistener("click", function DropdownButtonComponent_ng_template_9_ng_container_0_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r32); const item_r19 = i0.ɵɵnextContext().item; const ctx_r30 = i0.ɵɵnextContext(); const _r0 = i0.ɵɵreference(1); return i0.ɵɵresetView(item_r19 && ctx_r30.click(item_r19.onClick, _r0)); });
    i0.ɵɵelementStart(2, "div", 15);
    i0.ɵɵtemplate(3, DropdownButtonComponent_ng_template_9_ng_container_0_div_3_Template, 2, 2, "div", 4);
    i0.ɵɵelementStart(4, "div", 16);
    i0.ɵɵtemplate(5, DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_5_Template, 2, 1, "ng-container", 4);
    i0.ɵɵtemplate(6, DropdownButtonComponent_ng_template_9_ng_container_0_ng_container_6_Template, 2, 1, "ng-container", 4);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext().item;
    const ctx_r20 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", item_r19 && item_r19.klass)("title", ctx_r20.language.getFieldLabel(item_r19 == null ? null : item_r19.titleKey) || (item_r19 == null ? null : item_r19.title) || "");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", item_r19.icon);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", item_r19 && item_r19.label);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r19 && !item_r19.label && item_r19.labelKey);
} }
function DropdownButtonComponent_ng_template_9_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r35 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "scrm-dropdown-submenu", 19);
    i0.ɵɵlistener("item-clicked", function DropdownButtonComponent_ng_template_9_ng_container_1_Template_scrm_dropdown_submenu_item_clicked_1_listener() { i0.ɵɵrestoreView(_r35); const ctx_r34 = i0.ɵɵnextContext(2); const _r0 = i0.ɵɵreference(1); return i0.ɵɵresetView(ctx_r34.close(_r0)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r19 = i0.ɵɵnextContext().item;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", item_r19);
} }
function DropdownButtonComponent_ng_template_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, DropdownButtonComponent_ng_template_9_ng_container_0_Template, 7, 5, "ng-container", 4);
    i0.ɵɵtemplate(1, DropdownButtonComponent_ng_template_9_ng_container_1_Template, 2, 1, "ng-container", 4);
} if (rf & 2) {
    const item_r19 = ctx.item;
    const ctx_r7 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", item_r19 && !ctx_r7.isDropdown(item_r19));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r19 && ctx_r7.isDropdown(item_r19));
} }
class DropdownButtonComponent {
    constructor(language, systemConfigStore) {
        this.language = language;
        this.systemConfigStore = systemConfigStore;
        this.disabled = false;
        this.autoClose = true;
        this.sections = [];
        this.sectionsEnabled = false;
        this.charSize = {
            minLength: 20,
            mediumLength: 20,
            maxLength: 20
        };
    }
    isDropdown(item) {
        if (!item) {
            return false;
        }
        return 'items' in item;
    }
    click(onClick, dropdown) {
        onClick();
        dropdown.close();
    }
    close(dropdown) {
        dropdown.close();
    }
    ngOnInit() {
        if (this.config && !this.config.placement) {
            this.config.placement = ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
        }
        this.sections = [];
        const sectionsConfig = this.config?.sections ?? {};
        if (emptyObject(sectionsConfig)) {
            this.sectionsEnabled = false;
            return;
        }
        this.sectionsEnabled = true;
        this.preprocessItems(this.config?.items ?? []);
        const characterSizes = this.systemConfigStore.getUi('navbar_truncate_character_sizes');
        this.charSize = { ...characterSizes };
    }
    preprocessItems(items) {
        const sectionsConfig = this.config?.sections ?? {};
        const sections = {};
        if (!items || !items.length) {
            return;
        }
        items.forEach(item => {
            const sectionKey = item?.section ?? 'default';
            let section = this.getSection(sectionsConfig, sectionKey, sections);
            section.items.push(item);
        });
        Object.keys(sectionsConfig).forEach(sectionKey => {
            const section = sections[sectionKey];
            if (section && section.items && section.items.length) {
                this.sections.push(section);
            }
        });
    }
    /**
     * Get section from map, initialize if not on map
     * @param sectionsConfig
     * @param sectionKey
     * @param sections
     * @protected
     */
    getSection(sectionsConfig, sectionKey, sections) {
        const sectionConfig = sectionsConfig[sectionKey] ?? {};
        let section = sections[sectionKey] ?? null;
        if (section === null) {
            section = deepClone(sectionConfig);
            section.items = [];
            sections[sectionKey] = section;
        }
        return section;
    }
    getPlacement() {
        if (this.config && !this.config.placement) {
            return ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
        }
        return this.config.placement;
    }
    static { this.ɵfac = function DropdownButtonComponent_Factory(t) { return new (t || DropdownButtonComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DropdownButtonComponent, selectors: [["scrm-dropdown-button"]], inputs: { config: "config", disabled: "disabled", autoClose: "autoClose" }, decls: 11, vars: 13, consts: [["ngbDropdown", "", 1, "d-inline-block", "dropdown-button", 3, "autoClose", "placement", "ngClass"], ["dropDown", "ngbDropdown"], ["ngbDropdownToggle", "", 3, "disabled", "ngClass", "title"], [3, "image", "klass", 4, "ngIf"], [4, "ngIf"], ["ngbDropdownMenu", ""], ["buttonTemplate", ""], [3, "image", "klass"], [3, "labelKey"], [3, "ngClass", "section-split", "last-section", "first-section", 4, "ngFor", "ngForOf"], [3, "ngClass"], [1, "dropdown-menu-item-header"], [4, "ngFor", "ngForOf"], [4, "ngTemplateOutlet", "ngTemplateOutletContext"], ["ngbDropdownItem", "", 3, "ngClass", "title", "click"], [1, "d-flex", "align-items-center"], [1, "dropdown-item-label", "flex-grow-1"], [3, "labelKey", "module", 4, "ngIf"], [3, "labelKey", "module"], [3, "item", "item-clicked"]], template: function DropdownButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0, 1)(2, "button", 2);
            i0.ɵɵtemplate(3, DropdownButtonComponent_scrm_image_3_Template, 1, 2, "scrm-image", 3);
            i0.ɵɵtemplate(4, DropdownButtonComponent_ng_container_4_Template, 3, 4, "ng-container", 4);
            i0.ɵɵtemplate(5, DropdownButtonComponent_ng_container_5_Template, 2, 1, "ng-container", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 5);
            i0.ɵɵtemplate(7, DropdownButtonComponent_ng_container_7_Template, 2, 1, "ng-container", 4);
            i0.ɵɵtemplate(8, DropdownButtonComponent_ng_container_8_Template, 2, 1, "ng-container", 4);
            i0.ɵɵelementEnd()();
            i0.ɵɵtemplate(9, DropdownButtonComponent_ng_template_9_Template, 2, 2, "ng-template", null, 6, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            i0.ɵɵclassProp("sectioned-dropdown-menu", ctx.sectionsEnabled);
            i0.ɵɵproperty("autoClose", ctx.autoClose)("placement", ctx.getPlacement())("ngClass", ctx.config.wrapperKlass);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("disabled", ctx.disabled)("ngClass", ctx.config.klass)("title", ctx.language.getFieldLabel(ctx.config.titleKey) || "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config.icon);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config.label);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.config.label && ctx.config.labelKey);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.sectionsEnabled);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.sectionsEnabled);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i2.NgTemplateOutlet, i3$1.NgbDropdown, i3$1.NgbDropdownToggle, i3$1.NgbDropdownMenu, i3$1.NgbDropdownItem, ImageComponent, DropdownSubmenuComponent, LabelComponent, TruncatePipe], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dropdown-button', changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div ngbDropdown\n     [autoClose]=\"autoClose\"\n     [placement]=\"getPlacement()\"\n     #dropDown=\"ngbDropdown\"\n     class=\"d-inline-block dropdown-button\"\n     [class.sectioned-dropdown-menu]=\"sectionsEnabled\"\n     [ngClass]=\"config.wrapperKlass\">\n    <button [disabled]=\"disabled\"\n            [ngClass]=\"config.klass\"\n            [title]=\"language.getFieldLabel(config.titleKey) || ''\"\n            ngbDropdownToggle>\n\n        <scrm-image *ngIf=\"config.icon\"\n                    [image]=\"config.icon\"\n                    [klass]=\"config.iconKlass || ''\"></scrm-image>\n\n        <ng-container *ngIf=\"config.label\">\n            {{ config.label | truncate: charSize.maxLength}}\n        </ng-container>\n\n        <ng-container *ngIf=\"!config.label && config.labelKey\">\n            <scrm-label [labelKey]=\"config.labelKey\"></scrm-label>\n        </ng-container>\n\n    </button>\n    <div ngbDropdownMenu>\n\n        <ng-container *ngIf=\"sectionsEnabled\">\n\n            <div *ngFor=\"let section of sections; last as isLast; first as isFirst\"\n                 [ngClass]=\"section.klass ?? ''\"\n                 [class.section-split]=\"!isFirst\"\n                 [class.last-section]=\"isLast\"\n                 [class.first-section]=\"isFirst\">\n                <div class=\"dropdown-menu-item-header\">\n                    <scrm-label [labelKey]=\"section.labelKey ?? section.label ?? ''\" ></scrm-label>\n                </div>\n\n                <ng-container *ngFor=\"let item of section.items; let last = last\">\n                    <ng-container *ngTemplateOutlet=\"buttonTemplate; context: { item: item }\"></ng-container>\n                </ng-container>\n\n            </div>\n\n        </ng-container>\n\n        <ng-container *ngIf=\"!sectionsEnabled\">\n            <ng-container *ngFor=\"let item of config.items\">\n                <ng-container *ngTemplateOutlet=\"buttonTemplate; context: { item: item }\"></ng-container>\n            </ng-container>\n        </ng-container>\n\n    </div>\n</div>\n\n\n<ng-template #buttonTemplate let-item=\"item\">\n\n    <ng-container *ngIf=\"item && !isDropdown(item)\">\n        <a ngbDropdownItem\n           [ngClass]=\"item && item.klass\"\n           [title]=\"(language.getFieldLabel(item?.titleKey) || item?.title) || ''\"\n           (click)=\"item && click(item.onClick, dropDown)\">\n            <div class=\"d-flex align-items-center\">\n                <div *ngIf=\"item.icon\">\n                    <scrm-image [image]=\"item.icon\" [klass]=\"item.iconKlass || ''\"></scrm-image>\n                </div>\n                <div class=\"dropdown-item-label flex-grow-1\">\n                    <ng-container *ngIf=\"item && item.label\">\n                        {{ item.label }}\n                    </ng-container>\n                    <ng-container *ngIf=\"item && !item.label && item.labelKey\">\n                        <scrm-label *ngIf=\"item && item.labelKey\" [labelKey]=\"item.labelKey\"\n                                    [module]=\"item.labelModule ?? ''\"></scrm-label>\n                    </ng-container>\n                </div>\n            </div>\n        </a>\n    </ng-container>\n\n    <ng-container *ngIf=\"item && isDropdown(item)\">\n        <scrm-dropdown-submenu (item-clicked)=\"close(dropDown)\" [item]=\"item\"></scrm-dropdown-submenu>\n    </ng-container>\n\n</ng-template>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: SystemConfigStore }]; }, { config: [{
            type: Input
        }], disabled: [{
            type: Input
        }], autoClose: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function GroupedButtonComponent_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r2 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", item_r2);
} }
function GroupedButtonComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GroupedButtonComponent_ng_container_1_ng_container_1_Template, 2, 1, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r0.config.items);
} }
class GroupedButtonComponent {
    static { this.ɵfac = function GroupedButtonComponent_Factory(t) { return new (t || GroupedButtonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GroupedButtonComponent, selectors: [["scrm-grouped-button"]], inputs: { config: "config" }, decls: 2, vars: 2, consts: [["role", "group", 1, "btn-group", "grouped-button", 3, "ngClass"], [4, "ngIf"], [4, "ngFor", "ngForOf"], [3, "config"]], template: function GroupedButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, GroupedButtonComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            let tmp_0_0;
            i0.ɵɵproperty("ngClass", (tmp_0_0 = ctx.config == null ? null : ctx.config.wrapperKlass) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config == null ? null : ctx.config.items);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, ButtonComponent], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupedButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-grouped-button', changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"btn-group grouped-button\" role=\"group\" [ngClass]=\"config?.wrapperKlass ?? ''\">\n    <ng-container *ngIf=\"config?.items\">\n        <ng-container *ngFor=\"let item of config.items\">\n            <scrm-button [config]=\"item\"></scrm-button>\n        </ng-container>\n    </ng-container>\n</div>\n" }]
    }], null, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ButtonGroupComponent_div_0_ng_container_1_scrm_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button", 4);
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("config", item_r3);
} }
function ButtonGroupComponent_div_0_ng_container_1_scrm_dropdown_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-dropdown-button", 4);
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("config", item_r3);
} }
function ButtonGroupComponent_div_0_ng_container_1_scrm_grouped_button_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-grouped-button", 4);
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("config", item_r3);
} }
function ButtonGroupComponent_div_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ButtonGroupComponent_div_0_ng_container_1_scrm_button_1_Template, 1, 1, "scrm-button", 3);
    i0.ɵɵtemplate(2, ButtonGroupComponent_div_0_ng_container_1_scrm_dropdown_button_2_Template, 1, 1, "scrm-dropdown-button", 3);
    i0.ɵɵtemplate(3, ButtonGroupComponent_div_0_ng_container_1_scrm_grouped_button_3_Template, 1, 1, "scrm-grouped-button", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r3 = ctx.$implicit;
    let tmp_0_0;
    let tmp_1_0;
    let tmp_2_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r3 && !((tmp_0_0 = item_r3 == null ? null : item_r3.items) !== null && tmp_0_0 !== undefined ? tmp_0_0 : ""));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r3 && ((tmp_1_0 = item_r3 == null ? null : item_r3.items) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "") && ((tmp_1_0 = item_r3 == null ? null : item_r3.type) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "dropdown") === "dropdown");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r3 && ((tmp_2_0 = item_r3 == null ? null : item_r3.items) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "") && ((tmp_2_0 = item_r3 == null ? null : item_r3.type) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "dropdown") === "grouped");
} }
function ButtonGroupComponent_div_0_scrm_dropdown_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-dropdown-button", 5);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config", ctx_r2.dropdownConfig);
} }
function ButtonGroupComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, ButtonGroupComponent_div_0_ng_container_1_Template, 4, 3, "ng-container", 1);
    i0.ɵɵtemplate(2, ButtonGroupComponent_div_0_scrm_dropdown_button_2_Template, 1, 1, "scrm-dropdown-button", 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵclassMap(ctx_r0.klass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r0.buttons.expanded);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.buttons.collapsed.length);
} }
class ButtonGroupComponent {
    constructor() {
        this.klass = '';
        this.buttons = {
            expanded: [],
            collapsed: [],
        };
    }
    ngOnInit() {
        this.sub = this.config$.subscribe(config => {
            this.internalConfig = { ...config };
            this.splitButtons();
        });
    }
    ngOnDestroy() {
        this.sub.unsubscribe();
    }
    buildDropdownConfig() {
        let buttonClasses = ['button-group-button'];
        if (this.internalConfig.buttonKlass && this.internalConfig.buttonKlass.length > 0) {
            buttonClasses = buttonClasses.concat(this.internalConfig.buttonKlass);
        }
        if (this?.internalConfig?.dropdownOptions?.klass) {
            buttonClasses = buttonClasses.concat(this.internalConfig.dropdownOptions.klass);
        }
        let wrapperClasses = ['button-group-dropdown'];
        const dropdownOptions = this.internalConfig.dropdownOptions;
        const optionsWrapperKlass = dropdownOptions && dropdownOptions.wrapperKlass;
        if (optionsWrapperKlass && optionsWrapperKlass.length > 0) {
            wrapperClasses = wrapperClasses.concat(optionsWrapperKlass);
        }
        this.dropdownConfig = {
            label: this.internalConfig.dropdownLabel,
            klass: [...buttonClasses],
            wrapperKlass: wrapperClasses,
            items: this.buttons.collapsed,
        };
        if (this.internalConfig.dropdownOptions && this.internalConfig.dropdownOptions.placement) {
            this.dropdownConfig.placement = this.internalConfig.dropdownOptions.placement;
        }
        if (this.internalConfig.dropdownOptions && this.internalConfig.dropdownOptions.icon) {
            this.dropdownConfig.icon = this.internalConfig.dropdownOptions.icon;
        }
    }
    getBreakpoint() {
        if (!this.internalConfig.breakpoint && this.internalConfig.breakpoint !== 0) {
            return 4;
        }
        return this.internalConfig.breakpoint;
    }
    splitButtons() {
        this.buttons.expanded = [];
        this.buttons.collapsed = [];
        if (!this.internalConfig.buttons || this.internalConfig.buttons.length < 1) {
            return;
        }
        let count = 0;
        const showAfterBreakpoint = this.internalConfig.showAfterBreakpoint ?? true;
        this.internalConfig.buttons.forEach(button => {
            if (!button) {
                return;
            }
            if (count < this.getBreakpoint()) {
                let classes = ['button-group-button'];
                if (this.internalConfig.buttonKlass && this.internalConfig.buttonKlass.length > 0) {
                    classes = classes.concat(this.internalConfig.buttonKlass);
                }
                const newButton = { ...button };
                Button.appendClasses(newButton, [...classes]);
                this.buttons.expanded.push(newButton);
            }
            else if (showAfterBreakpoint === true) {
                this.buttons.collapsed.push({ ...button });
            }
            count++;
        });
        this.buildDropdownConfig();
    }
    static { this.ɵfac = function ButtonGroupComponent_Factory(t) { return new (t || ButtonGroupComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ButtonGroupComponent, selectors: [["scrm-button-group"]], inputs: { config$: "config$", klass: "klass" }, decls: 1, vars: 1, consts: [[3, "class", 4, "ngIf"], [4, "ngFor", "ngForOf"], ["autoClose", "outside", 3, "config", 4, "ngIf"], [3, "config", 4, "ngIf"], [3, "config"], ["autoClose", "outside", 3, "config"]], template: function ButtonGroupComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ButtonGroupComponent_div_0_Template, 3, 4, "div", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.config$);
        } }, dependencies: [i2.NgForOf, i2.NgIf, ButtonComponent, DropdownButtonComponent, GroupedButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonGroupComponent, [{
        type: Component,
        args: [{ selector: 'scrm-button-group', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"config$\" [class]=\"klass\">\n    <ng-container *ngFor=\"let item of buttons.expanded\">\n        <scrm-button *ngIf=\"item && !(item?.items ?? '')\"\n                     [config]=\"item\">\n        </scrm-button>\n        <scrm-dropdown-button *ngIf=\"item && (item?.items ?? '') && ((item?.type ?? 'dropdown') === 'dropdown')\"\n                              [config]=\"item\">\n        </scrm-dropdown-button>\n        <scrm-grouped-button *ngIf=\"item && (item?.items ?? '') && ((item?.type ?? 'dropdown') === 'grouped')\"\n                              [config]=\"item\">\n        </scrm-grouped-button>\n    </ng-container>\n\n    <scrm-dropdown-button autoClose=\"outside\"\n                          *ngIf=\"buttons.collapsed.length\"\n                          [config]=\"dropdownConfig\"></scrm-dropdown-button>\n</div>\n" }]
    }], function () { return []; }, { config$: [{
            type: Input
        }], klass: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$j = {
    userPreferences: {},
    loading: false
};
let internalState$6 = deepClone(initialState$j);
let cache$$5 = null;
class UserPreferenceStore {
    constructor(collectionGQL, config, processService, localStorage) {
        this.collectionGQL = collectionGQL;
        this.config = config;
        this.processService = processService;
        this.localStorage = localStorage;
        this.store = new BehaviorSubject(internalState$6);
        this.state$ = this.store.asObservable();
        this.saveBufferStore = new BehaviorSubject(false);
        this.subs = [];
        this.resourceName = 'userPreferences';
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
                'value',
                'items'
            ]
        };
        /**
         * Public long-lived observable streams
         */
        this.userPreferences$ = this.state$.pipe(map(state => state.userPreferences), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading));
        const uiSettings = config.getConfigValue('ui') ?? {};
        const delay = uiSettings.user_preferences_save_delay ?? 5000;
        this.saveBuffer$ = this.saveBufferStore.asObservable().pipe(debounceTime(delay ?? 5000));
        this.subs.push(this.saveBuffer$.subscribe((value) => {
            if (!value) {
                return;
            }
            this.saveUiPreferences();
        }));
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        cache$$5 = null;
        this.updateState(deepClone(initialState$j));
        this.subs.forEach(sub => sub.unsubscribe());
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get user preferences value by key
     *
     * @param {string} key to retrieve
     * @returns any users preference
     */
    getUserPreference(key) {
        if (!internalState$6.userPreferences || !internalState$6.userPreferences[key]) {
            return null;
        }
        return internalState$6.userPreferences[key];
    }
    /**
     * Get ui user preferences value by key
     *
     * @param module
     * @param {string} key to retrieve
     * @returns any users preference
     */
    getUi(module, key) {
        const storageKey = module + '-' + key;
        const value = this.storageLoad(module, storageKey);
        if (value != null) {
            return value;
        }
        const ui = internalState$6?.userPreferences?.ui ?? {};
        return ui[storageKey] ?? null;
    }
    /**
     * Set user preferences value by key
     *
     * @param {string} module name
     * @param {string} key to retrieve
     * @param value
     * @returns any users preference
     */
    setUi(module, key, value) {
        const storageKey = module + '-' + key;
        this.storageSave(module, storageKey, value);
        const ui = internalState$6?.userPreferences?.ui ?? {};
        ui[storageKey] = value;
        internalState$6.userPreferences.ui = ui;
        this.saveBufferStore.next(true);
    }
    saveUiPreferences() {
        const processType = 'save-ui-user-preferences';
        const options = {
            preferences: internalState$6.userPreferences.ui
        };
        this.processService.submit(processType, options).pipe(take(1)).subscribe();
    }
    /**
     * Store the data in local storage
     *
     * @param {string} module to store in
     * @param {string} storageKey to store in
     * @param {} data to store
     */
    storageSave(module, storageKey, data) {
        let storage = this.localStorage.get(storageKey);
        if (!storage) {
            storage = {};
        }
        storage[module] = data;
        this.localStorage.set(storageKey, storage);
    }
    /**
     * Store the key in local storage
     *
     * @param {string} module to load from
     * @param {string} storageKey from load from
     */
    storageLoad(module, storageKey) {
        const storage = this.localStorage.get(storageKey);
        if (!storage || !storage[module]) {
            return null;
        }
        return storage[module];
    }
    /**
     * Initial UserPreferences load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @returns {object} Observable<any>
     */
    load() {
        this.updateState({ ...internalState$6, loading: true });
        return this.getUserPreferences().pipe(tap(userPreferences => {
            this.updateState({ ...internalState$6, userPreferences, loading: false });
        }));
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$5 !== null;
    }
    /**
     * Set pre-loaded preferences and cache
     */
    set(userPreferences) {
        cache$$5 = of(userPreferences).pipe(shareReplay(1));
        this.updateState({ ...internalState$6, userPreferences, loading: false });
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState$6 = state);
    }
    /**
     * Get UserPreferences cached Observable or call the backend
     *
     * @returns {object} Observable<any>
     */
    getUserPreferences() {
        if (cache$$5 == null) {
            cache$$5 = this.fetch().pipe(shareReplay(1));
        }
        return cache$$5;
    }
    /**
     * Fetch the User Preferences from the backend
     *
     * @returns {object} Observable<any>
     */
    fetch() {
        return this.collectionGQL
            .fetchAll(this.resourceName, this.fieldsMetadata).pipe(map(({ data }) => {
            const userPreferences = {};
            if (data.userPreferences && data.userPreferences.edges) {
                data.userPreferences.edges.forEach((edge) => {
                    if (!edge.node.items) {
                        return;
                    }
                    Object.keys(edge.node.items).forEach(key => {
                        userPreferences[key] = edge.node.items[key];
                    });
                });
            }
            return userPreferences;
        }));
    }
    static { this.ɵfac = function UserPreferenceStore_Factory(t) { return new (t || UserPreferenceStore)(i0.ɵɵinject(CollectionGQL), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(ProcessService), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UserPreferenceStore, factory: UserPreferenceStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserPreferenceStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: CollectionGQL }, { type: SystemConfigStore }, { type: ProcessService }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FormControlUtils {
    getTrimmedInputValue(inputValue) {
        // Handle the cases, when input values are not string e.g. multienums: String[]
        // Process the input, only when it's a string else return as it is
        if (typeof inputValue !== 'string') {
            return inputValue;
        }
        return inputValue.trim();
    }
    isEmptyInputValue(inputValue) {
        // Handle the cases, when input value is an string, array, objects or any other type
        return inputValue == null
            || typeof inputValue === 'undefined'
            || inputValue === ''
            || inputValue.length === 0;
    }
    isEmptyTrimmedInputValue(inputValue) {
        return this.isEmptyInputValue(this.getTrimmedInputValue(inputValue));
    }
    isEmptyBooleanInputValue(inputValue) {
        return this.isEmptyInputValue(inputValue) || inputValue === 'false' || inputValue === false || inputValue === '';
    }
    static { this.ɵfac = function FormControlUtils_Factory(t) { return new (t || FormControlUtils)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FormControlUtils, factory: FormControlUtils.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormControlUtils, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NumberFormatter {
    constructor(preferences, formUtils, locale) {
        this.preferences = preferences;
        this.formUtils = formUtils;
        this.locale = locale;
    }
    toUserFormat(value, options) {
        if (isVoid(value) || value === '') {
            return '';
        }
        if (isFalse(options?.metadata?.format ?? true)) {
            return value;
        }
        const formatted = formatNumber(Number(value), this.locale);
        return this.replaceSeparators(formatted);
    }
    toInternalFormat(value) {
        if (!value) {
            return value;
        }
        const decimalSymbol = this.getDecimalsSymbol() || '.';
        const groupSymbol = this.getGroupSymbol() || ',';
        let decimalSymbolRegex = new RegExp(decimalSymbol, 'g');
        if (decimalSymbol === '.') {
            decimalSymbolRegex = new RegExp('\\.', 'g');
        }
        let groupSymbolRegex = new RegExp(groupSymbol, 'g');
        if (groupSymbol === '.') {
            groupSymbolRegex = new RegExp('\\.', 'g');
        }
        value = value.replace(groupSymbolRegex, 'group_separator');
        value = value.replace(decimalSymbolRegex, 'decimal_separator');
        value = value.replace(/decimal_separator/g, '.');
        value = value.replace(/group_separator/g, '');
        return value;
    }
    getFloatUserFormatPattern() {
        const group = this.getGroupSymbol();
        const decimals = this.getDecimalsSymbol();
        let pattern = '^-?(';
        pattern += '(\\d{1,3}(\\' + group + '\\d{3})*(\\' + decimals + '\\d+)?)|';
        pattern += '\\d*|';
        pattern += '(\\d+(\\' + decimals + '\\d+)?)|';
        pattern += '(\\d+(\\.\\d+)?)';
        pattern += ')$';
        return pattern;
    }
    getIntUserFormatPattern() {
        const group = this.getGroupSymbol();
        let pattern = '^-?(';
        pattern += '(\\d{1,3}(\\' + group + '\\d{3})*)|';
        pattern += '\\d*';
        pattern += ')$';
        return pattern;
    }
    getGroupSymbol() {
        const separator = this.preferences.getUserPreference('num_grp_sep');
        if (separator) {
            return separator;
        }
        return ',';
    }
    getDecimalsSymbol() {
        const separator = this.preferences.getUserPreference('dec_sep');
        if (separator) {
            return separator;
        }
        return '.';
    }
    replaceSeparators(transformed) {
        if (!transformed) {
            return transformed;
        }
        transformed = transformed.replace(/,/g, 'group_separator');
        transformed = transformed.replace(/\./g, 'decimal_separator');
        const decimalSymbol = this.getDecimalsSymbol() || '.';
        const groupSymbol = this.getGroupSymbol() || ',';
        transformed = transformed.replace(/decimal_separator/g, decimalSymbol);
        transformed = transformed.replace(/group_separator/g, groupSymbol);
        return transformed;
    }
    validateIntUserFormat(inputValue) {
        const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);
        if (this.formUtils.isEmptyInputValue(trimmedInputValue)) {
            return false;
        }
        const regex = new RegExp(this.getIntUserFormatPattern());
        return !regex.test(trimmedInputValue);
    }
    validateFloatUserFormat(inputValue) {
        const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);
        if (this.formUtils.isEmptyInputValue(trimmedInputValue)) {
            return false;
        }
        const regex = new RegExp(this.getFloatUserFormatPattern());
        return !regex.test(trimmedInputValue);
    }
    static { this.ɵfac = function NumberFormatter_Factory(t) { return new (t || NumberFormatter)(i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(FormControlUtils), i0.ɵɵinject(LOCALE_ID)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NumberFormatter, factory: NumberFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NumberFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: UserPreferenceStore }, { type: FormControlUtils }, { type: undefined, decorators: [{
                type: Inject,
                args: [LOCALE_ID]
            }] }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DatetimeFormatter {
    constructor(preferences, formUtils, locale) {
        this.preferences = preferences;
        this.formUtils = formUtils;
        this.locale = locale;
        this.format$ = this.preferences.userPreferences$.pipe(map(() => {
            const date = this.getDateFormat();
            const time = this.getTimeFormat();
            return { date, time };
        }));
    }
    getDateFormat() {
        const dateFormatPreference = this.preferences.getUserPreference('date_format');
        if (dateFormatPreference) {
            return dateFormatPreference;
        }
        return this.getInternalDateFormat();
    }
    getTimeFormat() {
        const timeFormatPreference = this.preferences.getUserPreference('time_format');
        if (timeFormatPreference) {
            let format = timeFormatPreference;
            if (format.includes('aaaaaa')) {
                format = format.replace('aaaaaa', 'aaaaa\'m\'');
            }
            return format;
        }
        return this.getInternalTimeFormat();
    }
    getDateTimeFormat() {
        const dateFormat = this.getDateFormat();
        const timeFormat = this.getTimeFormat();
        return dateFormat + ' ' + timeFormat;
    }
    getInternalDateFormat() {
        return 'yyyy-MM-dd';
    }
    getInternalTimeFormat() {
        return 'HH:mm:ss';
    }
    getInternalDateTimeFormat() {
        const dateFormat = this.getInternalDateFormat();
        const timeFormat = this.getInternalTimeFormat();
        return dateFormat + ' ' + timeFormat;
    }
    getInternalFormat() {
        return this.getInternalDateTimeFormat();
    }
    getUserFormat() {
        return this.getDateTimeFormat();
    }
    /**
     * Format Internal Date to User. It assumes internal date is in GMT/UTC
     *
     * @param dateString
     * @param options
     */
    toUserFormat(dateString, options) {
        const fromFormat = (options && options.fromFormat) || this.getInternalFormat();
        const toFormat = (options && options.toFormat) || this.getUserFormat();
        if (dateString) {
            const dateTime = this.toDateTime(dateString, fromFormat, {
                zone: 'GMT'
            });
            if (!dateTime.isValid) {
                return dateString;
            }
            return formatDate(dateTime.toJSDate(), toFormat, this.locale, this.userTimeZone());
        }
        return '';
    }
    /**
     * Format User Date to Internal format. It assumes the date is in the user timezone
     *
     * @param dateString
     * @param options
     */
    toInternalFormat(dateString, options) {
        const fromFormat = (options && options.fromFormat) || this.getUserFormat();
        if (dateString) {
            let date = this.toDateTime(dateString, fromFormat, {
                zone: this.preferences.getUserPreference('timezone')
            });
            return formatDate(date.toJSDate(), this.getInternalFormat(), this.locale, 'GMT');
        }
        return '';
    }
    formatDateTime(dateString, format, fromFormat = '', locale = this.locale, timezone = '') {
        const dateTime = this.toDateTime(dateString, fromFormat);
        if (!dateTime.isValid) {
            return dateString;
        }
        return formatDate(dateTime.toJSDate(), format, locale, timezone);
    }
    toDateTime(datetimeString, fromFormat = '', options) {
        if (!datetimeString) {
            return DateTime.invalid('empty');
        }
        if (fromFormat) {
            return DateTime.fromFormat(datetimeString, fromFormat, options);
        }
        let dateTime = this.fromUserFormat(datetimeString, options);
        if (!dateTime.isValid) {
            dateTime = this.fromInternalFormat(datetimeString, options);
        }
        return dateTime;
    }
    userDateTimeFormatToStruct(datetime) {
        if (!datetime) {
            return null;
        }
        const dateTime = this.toDateTime(datetime, '', {
            zone: this.preferences.getUserPreference('timezone')
        });
        if (!dateTime.isValid) {
            return null;
        }
        return {
            date: {
                day: dateTime.day,
                month: dateTime.month,
                year: dateTime.year
            },
            time: {
                hour: dateTime.hour,
                minute: dateTime.minute,
                second: dateTime.second,
            }
        };
    }
    internalDateTimeFormatToStruct(datetime) {
        if (!datetime) {
            return null;
        }
        const dateTime = this.toDateTime(datetime, this.getInternalDateTimeFormat(), {
            zone: 'GMT'
        });
        const rezoned = dateTime.setZone(this.preferences.getUserPreference('timezone'));
        if (!dateTime.isValid) {
            return null;
        }
        return {
            date: {
                day: rezoned.day,
                month: rezoned.month,
                year: rezoned.year
            },
            time: {
                hour: rezoned.hour,
                minute: rezoned.minute,
                second: rezoned.second,
            }
        };
    }
    userDateFormatToStruct(datetime) {
        if (!datetime) {
            return null;
        }
        const dateTime = this.toDateTime(datetime, '', {
            zone: this.preferences.getUserPreference('timezone')
        });
        if (!dateTime.isValid) {
            return null;
        }
        return {
            day: dateTime.day,
            month: dateTime.month,
            year: dateTime.year
        };
    }
    dateFormatToStruct(datetime, fromFormat = '') {
        if (!datetime) {
            return null;
        }
        const dateTime = this.toDateTime(datetime, fromFormat);
        if (!dateTime.isValid) {
            return null;
        }
        return {
            day: dateTime.day,
            month: dateTime.month,
            year: dateTime.year
        };
    }
    userTimeFormatToStruct(datetime) {
        if (!datetime) {
            return null;
        }
        const dateTime = this.toDateTime(datetime, '', {
            zone: this.preferences.getUserPreference('timezone')
        });
        if (!dateTime.isValid) {
            return null;
        }
        return {
            hour: dateTime.hour,
            minute: dateTime.minute,
            second: dateTime.second
        };
    }
    fromUserFormat(datetime, options, formatOptions) {
        // ensure datetime is in user format.
        datetime = this.toUserFormat(datetime, formatOptions);
        datetime = datetime.toString();
        datetime = datetime.replace('a', 'A');
        datetime = datetime.replace('p', 'P');
        datetime = datetime.replace('m', 'M');
        let format = this.getUserFormat();
        format = format.replace('aaaaa\'m\'', 'a');
        return DateTime.fromFormat(datetime, format, options);
    }
    fromInternalFormat(datetime, options) {
        const format = this.getInternalFormat();
        return DateTime.fromFormat(datetime.toString(), format, options);
    }
    validateUserFormat(inputValue, userFormat = '') {
        const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);
        if (this.formUtils.isEmptyInputValue(trimmedInputValue)) {
            return false;
        }
        const dateTime = this.fromUserFormat(trimmedInputValue, {}, { fromFormat: userFormat });
        return !dateTime.isValid;
    }
    userTimeZone() {
        let userTZ = this.preferences.getUserPreference('timezone') ?? 'GMT';
        if (!userTZ) {
            userTZ = 'GMT';
        }
        const milliseconds = DateTime.now().setZone(userTZ).toMillis();
        return IANAZone.create(userTZ).formatOffset(milliseconds, 'techie');
    }
    static { this.ɵfac = function DatetimeFormatter_Factory(t) { return new (t || DatetimeFormatter)(i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(FormControlUtils), i0.ɵɵinject(LOCALE_ID)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DatetimeFormatter, factory: DatetimeFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DatetimeFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: UserPreferenceStore }, { type: FormControlUtils }, { type: undefined, decorators: [{
                type: Inject,
                args: [LOCALE_ID]
            }] }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CurrencyFormatter {
    constructor(preferences, numberFormatter, locale) {
        this.preferences = preferences;
        this.numberFormatter = numberFormatter;
        this.locale = locale;
    }
    toUserFormat(value, options = null) {
        if (isVoid(value) || value === '') {
            return '';
        }
        const symbol = (options && options.symbol) || this.getSymbol();
        const code = (options && options.code) || this.getCode();
        let digits = null;
        if (options && options.digits !== null && isFinite(options.digits)) {
            digits = options.digits;
        }
        const digitsInfo = this.getDigitsInfo(digits);
        let formatted;
        if (options && options.mode === 'edit') {
            formatted = formatNumber(Number(value), this.locale, digitsInfo);
            return this.replaceSeparators(formatted);
        }
        formatted = formatCurrency(Number(value), this.locale, symbol, code, digitsInfo);
        return this.replaceSeparators(formatted);
    }
    toInternalFormat(value) {
        if (!value) {
            return '';
        }
        const transformed = value.replace(this.getSymbol(), '');
        return this.numberFormatter.toInternalFormat(transformed);
    }
    getCurrencyFormat() {
        const currencyFormat = this.preferences.getUserPreference('currency');
        if (currencyFormat) {
            return currencyFormat;
        }
        return this.getDefaultFormat();
    }
    getDefaultFormat() {
        return {
            iso4217: 'USD',
            name: 'US Dollars',
            symbol: '$'
        };
    }
    getCode() {
        return this.getCurrencyFormat().iso4217;
    }
    getSymbol() {
        return this.getCurrencyFormat().symbol;
    }
    getDigits() {
        const digits = this.preferences.getUserPreference('default_currency_significant_digits');
        if (digits) {
            return digits;
        }
        return 2;
    }
    getDigitsInfo(definedDigits) {
        let digitInfo = '1.2-2';
        let digits = this.getDigits();
        if (definedDigits !== null && isFinite(definedDigits)) {
            digits = definedDigits;
        }
        if (digits !== null && isFinite(digits)) {
            if (digits < 1) {
                digitInfo = '1.0-0';
            }
            else {
                digitInfo = `1.${digits}-${digits}`;
            }
        }
        return digitInfo;
    }
    replaceSeparators(transformed) {
        return this.numberFormatter.replaceSeparators(transformed);
    }
    static { this.ɵfac = function CurrencyFormatter_Factory(t) { return new (t || CurrencyFormatter)(i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(NumberFormatter), i0.ɵɵinject(LOCALE_ID)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CurrencyFormatter, factory: CurrencyFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: UserPreferenceStore }, { type: NumberFormatter }, { type: undefined, decorators: [{
                type: Inject,
                args: [LOCALE_ID]
            }] }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateFormatter extends DatetimeFormatter {
    getInternalFormat() {
        return this.getInternalDateFormat();
    }
    getUserFormat() {
        return this.getDateFormat();
    }
    /**
     * Format User Date to Internal format. It assumes the date is always in GMT
     *
     * @param dateString
     * @param options
     */
    toInternalFormat(dateString, options) {
        const fromFormat = (options && options.fromFormat) || this.getUserFormat();
        if (dateString) {
            let date = this.toDateTime(dateString, fromFormat);
            if (!date || !date.isValid) {
                date = this.toDateTime(dateString);
            }
            return formatDate(date.toJSDate(), this.getInternalFormat(), this.locale);
        }
        return '';
    }
    /**
     * Format Internal Date to User. It assumes internal date is in GMT/UTC
     *
     * @param dateString
     * @param options
     */
    toUserFormat(dateString, options) {
        const fromFormat = (options && options.fromFormat) || this.getInternalFormat();
        const toFormat = (options && options.toFormat) || this.getUserFormat();
        if (dateString) {
            const dateTime = this.toDateTime(dateString, fromFormat);
            if (!dateTime.isValid) {
                return dateString;
            }
            return formatDate(dateTime.toJSDate(), toFormat, this.locale);
        }
        return '';
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵDateFormatter_BaseFactory; return function DateFormatter_Factory(t) { return (ɵDateFormatter_BaseFactory || (ɵDateFormatter_BaseFactory = i0.ɵɵgetInheritedFactory(DateFormatter)))(t || DateFormatter); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateFormatter, factory: DateFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PhoneFormatter {
    constructor(formUtils, systemConfigStore) {
        this.formUtils = formUtils;
        this.systemConfigStore = systemConfigStore;
    }
    toUserFormat(value) {
        return value;
    }
    toInternalFormat(value) {
        return value;
    }
    getDefaultFormatPattern() {
        const validations = this.systemConfigStore.getUi('validations');
        const defaultRegex = validations?.regex?.phone || '';
        return defaultRegex;
    }
    validateUserFormat(inputValue, regexPattern) {
        const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);
        if (this.formUtils.isEmptyInputValue(trimmedInputValue)) {
            return false;
        }
        const regex = new RegExp(regexPattern);
        return !regex.test(trimmedInputValue);
    }
    static { this.ɵfac = function PhoneFormatter_Factory(t) { return new (t || PhoneFormatter)(i0.ɵɵinject(FormControlUtils), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PhoneFormatter, factory: PhoneFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PhoneFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FormControlUtils }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DataTypeFormatter {
    constructor(currencyFormatter, numberFormatter, dateFormatter, datetimeFormatter, phoneFormatter) {
        this.currencyFormatter = currencyFormatter;
        this.numberFormatter = numberFormatter;
        this.dateFormatter = dateFormatter;
        this.datetimeFormatter = datetimeFormatter;
        this.phoneFormatter = phoneFormatter;
        this.map = {};
        this.map.int = numberFormatter;
        this.map.float = numberFormatter;
        this.map.date = dateFormatter;
        this.map.datetime = datetimeFormatter;
        this.map.currency = currencyFormatter;
        this.map.phone = phoneFormatter;
    }
    toUserFormat(dataType, value, options) {
        if (!dataType) {
            return value;
        }
        const formatter = this.map[dataType];
        if (!formatter) {
            return value;
        }
        return formatter.toUserFormat(value, options);
    }
    toInternalFormat(dataType, value) {
        if (!dataType) {
            return value;
        }
        const formatter = this.map[dataType];
        if (!formatter) {
            return value;
        }
        return formatter.toInternalFormat(value);
    }
    static { this.ɵfac = function DataTypeFormatter_Factory(t) { return new (t || DataTypeFormatter)(i0.ɵɵinject(CurrencyFormatter), i0.ɵɵinject(NumberFormatter), i0.ɵɵinject(DateFormatter), i0.ɵɵinject(DatetimeFormatter), i0.ɵɵinject(PhoneFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DataTypeFormatter, factory: DataTypeFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DataTypeFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: CurrencyFormatter }, { type: NumberFormatter }, { type: DateFormatter }, { type: DatetimeFormatter }, { type: PhoneFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DynamicLabelService {
    constructor(typeFormatter, language, configs, preferences) {
        this.typeFormatter = typeFormatter;
        this.language = language;
        this.configs = configs;
        this.preferences = preferences;
        this.valuePipes = {};
        this.fieldPipes = {};
        this.valuePipes.int = (value) => this.valueTypeFormat('int', value);
        this.valuePipes.float = (value) => this.valueTypeFormat('float', value);
        this.valuePipes.date = (value) => this.valueTypeFormat('date', value);
        this.valuePipes.datetime = (value) => this.valueTypeFormat('datetime', value);
        this.valuePipes.currency = (value) => this.valueTypeFormat('currency', value);
        this.valuePipes.enum = (value, filterArguments = []) => this.enumFormat(value, filterArguments);
        this.fieldPipes.int = (value) => this.fieldTypeFormat('int', value);
        this.fieldPipes.float = (value) => this.fieldTypeFormat('float', value);
        this.fieldPipes.date = (value) => this.fieldTypeFormat('date', value);
        this.fieldPipes.datetime = (value) => this.fieldTypeFormat('datetime', value);
        this.fieldPipes.currency = (value) => this.fieldTypeFormat('currency', value);
        this.fieldPipes.phone = (value) => this.fieldTypeFormat('phone', value);
        this.fieldPipes.enum = (value) => this.enumFieldFormat(value);
        this.fieldPipes.dynamicenum = (value) => this.enumFieldFormat(value);
        this.fieldPipes.multienum = (value) => this.multiEnumFormat(value);
    }
    addValuePipe(name, processor) {
        this.valuePipes[name] = processor;
    }
    addFieldPipe(name, processor) {
        this.fieldPipes[name] = processor;
    }
    parse(template, context, fields) {
        if (!template) {
            return template;
        }
        const regex = /({{[\s\S]+?}})/g;
        const matches = template.match(regex);
        if (!matches || matches.length < 1) {
            return template;
        }
        let parsedTemplate = template;
        const module = (context && context.module) || '';
        matches.forEach((regexMatch) => {
            if (!parsedTemplate.includes(regexMatch)) {
                return;
            }
            let filter = '';
            let filterArguments = [];
            let value = '';
            let source = 'context';
            let parts = [];
            let variableName = '' + regexMatch;
            variableName = variableName.replace('{{', '');
            variableName = variableName.replace('}}', '');
            variableName = variableName.trim();
            let path = variableName;
            if (variableName.includes('|')) {
                const [name, pipe, ...others] = variableName.split('|');
                filter = pipe.trim();
                if (pipe.trim().includes(':')) {
                    let [filterType, ...filterArgs] = pipe.trim().split(':');
                    filter = filterType.trim();
                    filterArguments = filterArgs;
                }
                variableName = name.trim();
                path = name.trim();
            }
            if (variableName.includes('.')) {
                parts = variableName.split('.');
                source = parts[0];
                variableName = parts[1];
            }
            let sourceValues = context;
            if (source === 'fields') {
                sourceValues = fields;
            }
            if (source === 'fields') {
                if (!sourceValues || !(variableName in sourceValues)) {
                    parsedTemplate = parsedTemplate.replace(regexMatch, value);
                    return;
                }
                const field = fields[variableName];
                if (!field) {
                    parsedTemplate = parsedTemplate.replace(regexMatch, '');
                    return;
                }
                if (parts[2] && parts[2] === 'value' && field.type in this.fieldPipes) {
                    value = this.fieldPipes[field.type](field);
                    parsedTemplate = parsedTemplate.replace(regexMatch, value);
                    return;
                }
                if (parts[2] && parts[2] === 'label') {
                    value = this.getFieldLabel(field.labelKey, module);
                    parsedTemplate = parsedTemplate.replace(regexMatch, value);
                    return;
                }
                value = get({ fields }, path, '');
                parsedTemplate = parsedTemplate.replace(regexMatch, value);
                return;
            }
            if (source === 'config') {
                parsedTemplate = this.parseObjectContext(variableName, parsedTemplate, regexMatch, filter, filterArguments, (key) => {
                    return this.configs.getConfigValue(key);
                });
                return;
            }
            if (source === 'preferences') {
                parsedTemplate = this.parseObjectContext(variableName, parsedTemplate, regexMatch, filter, filterArguments, (key) => {
                    return this.preferences.getUserPreference(key);
                });
                return;
            }
            if (!sourceValues || !(variableName in sourceValues)) {
                parsedTemplate = parsedTemplate.replace(regexMatch, value);
                return;
            }
            value = get({ context }, path, '');
            if (filter in this.valuePipes) {
                value = this.valuePipes[filter](value);
            }
            parsedTemplate = parsedTemplate.replace(regexMatch, value);
        });
        return parsedTemplate;
    }
    valueTypeFormat(type, value) {
        return this.typeFormatter.toUserFormat(type, value);
    }
    enumFormat(value, filterArguments) {
        const options = filterArguments[0] ?? '';
        if (!options || !value) {
            return '';
        }
        return this.language.getListLabel(options, value);
    }
    fieldTypeFormat(type, field) {
        return this.typeFormatter.toUserFormat(type, field.value);
    }
    enumFieldFormat(field) {
        if (isVoid(field.definition.options) || isVoid(field.value)) {
            return '';
        }
        return this.language.getListLabel(field.definition.options, field.value);
    }
    multiEnumFormat(field) {
        if (isVoid(field.definition.options) || isVoid(field.valueList) || field.valueList.length < 1) {
            return '';
        }
        const result = [];
        field.valueList.forEach(value => {
            if (isVoid(value)) {
                return;
            }
            result.push(this.language.getListLabel(field.definition.options, value));
        });
        return result.join(', ');
    }
    getFieldLabel(labelKey, module = '') {
        if (isVoid(labelKey)) {
            return '';
        }
        return this.language.getFieldLabel(labelKey, module);
    }
    parseObjectContext(variableName, parsedTemplate, regexMatch, filter, filterArguments, getter) {
        let entryKey = variableName;
        if (variableName.includes('.')) {
            let [key, ...others] = variableName.split('.');
            entryKey = key;
        }
        let value = getter(entryKey);
        if (variableName.includes('.') && typeof value === 'object') {
            value = get({ value }, variableName, '');
        }
        if (!value || typeof value === 'object') {
            return parsedTemplate.replace(regexMatch, '');
        }
        if (filter in this.valuePipes) {
            value = this.valuePipes[filter](value, filterArguments);
        }
        return parsedTemplate.replace(regexMatch, value);
    }
    static { this.ɵfac = function DynamicLabelService_Factory(t) { return new (t || DynamicLabelService)(i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DynamicLabelService, factory: DynamicLabelService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DynamicLabelService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DataTypeFormatter }, { type: LanguageStore }, { type: SystemConfigStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DynamicLabelComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "span", 1);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.parsedLabel);
} }
class DynamicLabelComponent {
    constructor(dynamicLabels, language) {
        this.dynamicLabels = dynamicLabels;
        this.language = language;
        this.template = '';
        this.labelKey = '';
        this.context = {};
        this.fields = {};
        this.module = null;
        this.parsedLabel = '';
    }
    ngOnInit() {
        this.vm$ = this.language.vm$.pipe(tap(() => {
            if (this.labelKey) {
                this.template = this.language.getFieldLabel(this.labelKey, this.module);
            }
            this.parseLabel();
        }));
    }
    ngOnChanges(changes) {
        if (changes.template || changes.context || changes.labelKey || changes.fields) {
            this.parseLabel();
        }
    }
    parseLabel() {
        this.parsedLabel = this.dynamicLabels.parse(this.template, this.context, this.fields);
    }
    static { this.ɵfac = function DynamicLabelComponent_Factory(t) { return new (t || DynamicLabelComponent)(i0.ɵɵdirectiveInject(DynamicLabelService), i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DynamicLabelComponent, selectors: [["scrm-dynamic-label"]], inputs: { template: "template", labelKey: "labelKey", context: "context", fields: "fields", module: "module" }, features: [i0.ɵɵNgOnChangesFeature], decls: 2, vars: 3, consts: [[4, "ngIf"], [1, "dynamic-label"]], template: function DynamicLabelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, DynamicLabelComponent_ng_container_0_Template, 3, 1, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DynamicLabelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dynamic-label', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <span class=\"dynamic-label\">{{parsedLabel}}</span>\n</ng-container>\n" }]
    }], function () { return [{ type: DynamicLabelService }, { type: LanguageStore }]; }, { template: [{
            type: Input
        }], labelKey: [{
            type: Input
        }], context: [{
            type: Input
        }], fields: [{
            type: Input
        }], module: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InlineLoadingSpinnerComponent {
    constructor() {
        this.klass = '';
    }
    ngOnInit() {
    }
    static { this.ɵfac = function InlineLoadingSpinnerComponent_Factory(t) { return new (t || InlineLoadingSpinnerComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: InlineLoadingSpinnerComponent, selectors: [["scrm-inline-loading-spinner"]], inputs: { klass: "klass" }, decls: 4, vars: 3, consts: [[1, "bounce1"], [1, "bounce2"], [1, "bounce3"]], template: function InlineLoadingSpinnerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div");
            i0.ɵɵelement(1, "div", 0)(2, "div", 1)(3, "div", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMapInterpolate1("inline-spinner ", ctx.klass, "");
        } }, styles: [".inline-spinner[_ngcontent-%COMP%]{text-align:center}.inline-spinner[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{border-radius:100%;display:inline-block;animation:_ngcontent-%COMP%_sk-bouncedelay 1.4s infinite ease-in-out both}.inline-spinner[_ngcontent-%COMP%]   .bounce1[_ngcontent-%COMP%]{animation-delay:-.32s}.inline-spinner[_ngcontent-%COMP%]   .bounce2[_ngcontent-%COMP%]{animation-delay:-.16s}@keyframes _ngcontent-%COMP%_sk-bouncedelay{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}"] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InlineLoadingSpinnerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-inline-loading-spinner', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"inline-spinner {{klass}}\">\n    <div class=\"bounce1\"></div>\n    <div class=\"bounce2\"></div>\n    <div class=\"bounce3\"></div>\n</div>\n", styles: [".inline-spinner{text-align:center}.inline-spinner>div{border-radius:100%;display:inline-block;animation:sk-bouncedelay 1.4s infinite ease-in-out both}.inline-spinner .bounce1{animation-delay:-.32s}.inline-spinner .bounce2{animation-delay:-.16s}@keyframes sk-bouncedelay{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}\n"] }]
    }], function () { return []; }, { klass: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ActionGroupMenuComponent_ng_container_0_ng_container_2_scrm_button_group_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button-group", 2);
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("config$", ctx_r5.config$)("klass", ctx_r5.buttonGroupClass);
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ActionGroupMenuComponent_ng_container_0_ng_container_2_scrm_button_group_1_Template, 1, 2, "scrm-button-group", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.config$);
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_3_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-label", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r6.confirmationLabel);
} }
const _c0$L = function () { return {}; };
function ActionGroupMenuComponent_ng_container_0_ng_container_3_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-dynamic-label", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(3);
    let tmp_1_0;
    let tmp_2_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r7.confirmationDynamicLabel)("module", (tmp_1_0 = ctx_r7.actionContext == null ? null : ctx_r7.actionContext.module) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "")("fields", (tmp_2_0 = ctx_r7.actionContext == null ? null : ctx_r7.actionContext.record == null ? null : ctx_r7.actionContext.record.fields) !== null && tmp_2_0 !== undefined ? tmp_2_0 : i0.ɵɵpureFunction0(3, _c0$L));
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_3_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "scrm-button", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r8.inlineCancelButton);
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_3_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "scrm-button", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r9.inlineConfirmButton);
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵtemplate(2, ActionGroupMenuComponent_ng_container_0_ng_container_3_div_2_Template, 2, 1, "div", 4);
    i0.ɵɵtemplate(3, ActionGroupMenuComponent_ng_container_0_ng_container_3_div_3_Template, 2, 4, "div", 4);
    i0.ɵɵtemplate(4, ActionGroupMenuComponent_ng_container_0_ng_container_3_div_4_Template, 2, 1, "div", 5);
    i0.ɵɵtemplate(5, ActionGroupMenuComponent_ng_container_0_ng_container_3_div_5_Template, 2, 1, "div", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r3.confirmationLabel);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.confirmationDynamicLabel && !ctx_r3.confirmationLabel);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.inlineCancelButton);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.inlineConfirmButton);
} }
function ActionGroupMenuComponent_ng_container_0_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-inline-loading-spinner", 11);
    i0.ɵɵelementContainerEnd();
} }
function ActionGroupMenuComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵtemplate(2, ActionGroupMenuComponent_ng_container_0_ng_container_2_Template, 2, 1, "ng-container", 0);
    i0.ɵɵtemplate(3, ActionGroupMenuComponent_ng_container_0_ng_container_3_Template, 6, 4, "ng-container", 0);
    i0.ɵɵtemplate(4, ActionGroupMenuComponent_ng_container_0_ng_container_4_Template, 2, 0, "ng-container", 0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("", ctx_r0.klass, " float-right action-group-menu");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.inlineConfirmationEnabled && !ctx_r0.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.inlineConfirmationEnabled && !ctx_r0.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.loading);
} }
class ActionGroupMenuComponent {
    constructor(languages, screenSize, systemConfigStore) {
        this.languages = languages;
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.klass = '';
        this.buttonClass = 'btn btn-sm';
        this.buttonGroupClass = '';
        this.actionLimitConfig = 'recordview_actions_limits';
        this.configState = new BehaviorSubject({ buttons: [] });
        this.config$ = this.configState.asObservable();
        this.inlineConfirmationEnabled = false;
        this.confirmationLabel = '';
        this.confirmationDynamicLabel = '';
        this.inlineCancelButton = null;
        this.inlineConfirmButton = null;
        this.loading = false;
        this.buttonGroupDropdownClass = 'dropdown-button-secondary';
        this.screen = ScreenSize.Medium;
        this.defaultBreakpoint = 4;
    }
    ngOnInit() {
        this.vm$ = this.config?.getActions().pipe(combineLatestWith(this.screenSize.screenSize$, this.languages.vm$), map(([actions, screenSize, languages]) => {
            if (screenSize) {
                this.screen = screenSize;
            }
            this.configState.next(this.getButtonGroupConfig(actions));
            return { actions, screenSize, languages };
        }));
    }
    isXSmallScreen() {
        return this.screen === ScreenSize.XSmall;
    }
    getButtonGroupConfig(actions) {
        const expanded = [];
        const collapsed = [];
        actions.forEach((action) => {
            const button = this.buildButton(action);
            if (action.params && action.params.collapsedMobile && this.isXSmallScreen()) {
                collapsed.push(button);
                return;
            }
            if (action.params && action.params.expanded) {
                expanded.push(button);
                return;
            }
            collapsed.push(button);
        });
        const collapseButtons = this.config.collapseButtons ?? true;
        let breakpoint = actions.length;
        if (collapseButtons === true) {
            breakpoint = this.getBreakpoint();
            if (expanded.length < breakpoint) {
                breakpoint = expanded.length;
            }
        }
        const buttons = expanded.concat(collapsed);
        return {
            buttonKlass: [this.buttonClass],
            dropdownLabel: this.languages.getAppString('LBL_ACTIONS') || '',
            breakpoint,
            dropdownOptions: {
                placement: ['bottom-right'],
                wrapperKlass: [(this.buttonGroupDropdownClass)]
            },
            buttons
        };
    }
    getBreakpoint() {
        const breakpointMap = this.systemConfigStore.getConfigValue(this.actionLimitConfig);
        if (this.screen && breakpointMap && breakpointMap[this.screen]) {
            this.breakpoint = breakpointMap[this.screen];
            return this.breakpoint;
        }
        if (this.breakpoint) {
            return this.breakpoint;
        }
        return this.defaultBreakpoint;
    }
    buildButton(action) {
        const button = {
            label: action.label || '',
            labelModule: this?.actionContext?.module ?? '',
            labelKey: action.labelKey || '',
            klass: this.buttonClass,
            titleKey: action.titleKey || '',
            onClick: () => {
                const inlineConfirmation = action?.params?.inlineConfirmation ?? false;
                if (inlineConfirmation) {
                    this.triggerTemporaryLoading();
                    const callback = () => {
                        this.config.runAction(action, this.actionContext);
                    };
                    this.initInlineConfirmation(action, callback);
                    return;
                }
                this.config.runAction(action, this.actionContext);
            }
        };
        if (!button.label) {
            button.labelKey = action.labelKey ?? '';
        }
        const debounceClick = action?.params?.debounceClick ?? null;
        button.debounceClick = true;
        if (isFalse(debounceClick)) {
            button.debounceClick = false;
        }
        if (action.icon) {
            button.icon = action.icon;
        }
        if (action.status) {
            Button.appendClasses(button, [action.status]);
        }
        if (action.klass) {
            Button.appendClasses(button, action.klass);
        }
        return button;
    }
    triggerTemporaryLoading() {
        this.loading = true;
        const delay = parseInt(this.systemConfigStore.getUi('inline_confirmation_loading_delay')) ?? 200;
        setTimeout(() => {
            this.loading = false;
        }, delay);
    }
    initInlineConfirmation(action, callback) {
        const cancelConfig = action?.params?.inlineConfirmationButtons?.cancel ?? {};
        const confirmConfig = action?.params?.inlineConfirmationButtons?.confirm ?? {};
        this.confirmationLabel = action?.params?.confirmationLabel ?? '';
        this.confirmationDynamicLabel = action?.params?.confirmationDynamicLabel ?? '';
        this.inlineCancelButton = this.buildInlineCancelButton(cancelConfig);
        this.inlineConfirmButton = this.buildInlineConfirmButton(confirmConfig, callback);
        this.inlineConfirmationEnabled = true;
    }
    buildInlineCancelButton(config) {
        const defaults = {
            labelKey: 'LBL_NO',
            klass: 'btn btn-sm p-0 m-0 btn-link border-0 line-height-initial',
            debounceClick: true,
        };
        const button = { ...defaults, ...(config ?? {}) };
        button.onClick = () => {
            this.triggerTemporaryLoading();
            this.resetInlineConfirmation();
        };
        return button;
    }
    buildInlineConfirmButton(config, callback) {
        const defaults = {
            labelKey: 'LBL_YES',
            klass: 'btn btn-sm p-0 m-0 btn-link border-0 line-height-initial',
            debounceClick: true,
        };
        const button = { ...defaults, ...(config ?? {}) };
        button.onClick = () => {
            this.triggerTemporaryLoading();
            callback();
            this.resetInlineConfirmation();
        };
        return button;
    }
    resetInlineConfirmation() {
        this.inlineConfirmationEnabled = false;
        this.confirmationDynamicLabel = '';
        this.confirmationLabel = '';
        this.inlineConfirmButton = null;
        this.inlineCancelButton = null;
    }
    static { this.ɵfac = function ActionGroupMenuComponent_Factory(t) { return new (t || ActionGroupMenuComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ActionGroupMenuComponent, selectors: [["scrm-action-group-menu"]], inputs: { klass: "klass", buttonClass: "buttonClass", buttonGroupClass: "buttonGroupClass", actionContext: "actionContext", config: "config", actionLimitConfig: "actionLimitConfig" }, decls: 2, vars: 3, consts: [[4, "ngIf"], [3, "config$", "klass", 4, "ngIf"], [3, "config$", "klass"], [1, "d-flex", "align-items-start", "justify-content-end", "inline-confirmation"], ["class", "pl-1 inline-confirmation-label", 4, "ngIf"], ["class", "pl-1 inline-confirmation-button", 4, "ngIf"], [1, "pl-1", "inline-confirmation-label"], [3, "labelKey"], [3, "labelKey", "module", "fields"], [1, "pl-1", "inline-confirmation-button"], [3, "config"], ["klass", "inline-spinner-md"]], template: function ActionGroupMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ActionGroupMenuComponent_ng_container_0_Template, 5, 6, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, ButtonComponent, ButtonGroupComponent, LabelComponent, DynamicLabelComponent, InlineLoadingSpinnerComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionGroupMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-action-group-menu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <div class=\"{{klass}} float-right action-group-menu\">\n        <ng-container *ngIf=\"!inlineConfirmationEnabled && !loading\">\n            <scrm-button-group *ngIf=\"config$\" [config$]=\"config$\" [klass]=\"buttonGroupClass\"></scrm-button-group>\n        </ng-container>\n        <ng-container *ngIf=\"inlineConfirmationEnabled && !loading\">\n            <div class=\"d-flex align-items-start justify-content-end inline-confirmation\">\n                <div *ngIf=\"confirmationLabel\" class=\"pl-1 inline-confirmation-label\">\n                    <scrm-label [labelKey]=\"confirmationLabel\"></scrm-label>\n                </div>\n                <div *ngIf=\"confirmationDynamicLabel && !confirmationLabel\" class=\"pl-1 inline-confirmation-label\">\n                    <scrm-dynamic-label [labelKey]=\"confirmationDynamicLabel\"\n                                        [module]=\"actionContext?.module ?? ''\"\n                                        [fields]=\"actionContext?.record?.fields ?? {}\"\n                    >\n                    </scrm-dynamic-label>\n                </div>\n                <div *ngIf=\"inlineCancelButton\" class=\"pl-1 inline-confirmation-button\">\n                    <scrm-button [config]=\"inlineCancelButton\"></scrm-button>\n                </div>\n                <div *ngIf=\"inlineConfirmButton\" class=\"pl-1 inline-confirmation-button\">\n                    <scrm-button [config]=\"inlineConfirmButton\"></scrm-button>\n                </div>\n            </div>\n        </ng-container>\n        <ng-container *ngIf=\"loading\">\n            <scrm-inline-loading-spinner klass=\"inline-spinner-md\"></scrm-inline-loading-spinner>\n        </ng-container>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }]; }, { klass: [{
            type: Input
        }], buttonClass: [{
            type: Input
        }], buttonGroupClass: [{
            type: Input
        }], actionContext: [{
            type: Input
        }], config: [{
            type: Input
        }], actionLimitConfig: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ImageModule {
    static { this.ɵfac = function ImageModule_Factory(t) { return new (t || ImageModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ImageModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AngularSvgIconModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImageModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    ImageComponent
                ],
                exports: [
                    ImageComponent
                ],
                imports: [
                    CommonModule,
                    AngularSvgIconModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ImageModule, { declarations: [ImageComponent], imports: [CommonModule,
        AngularSvgIconModule], exports: [ImageComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DropdownSubmenuModule {
    static { this.ɵfac = function DropdownSubmenuModule_Factory(t) { return new (t || DropdownSubmenuModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DropdownSubmenuModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule,
            NgbModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownSubmenuModule, [{
        type: NgModule,
        args: [{
                declarations: [DropdownSubmenuComponent],
                exports: [
                    DropdownSubmenuComponent
                ],
                imports: [
                    CommonModule,
                    ImageModule,
                    NgbModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DropdownSubmenuModule, { declarations: [DropdownSubmenuComponent], imports: [CommonModule,
        ImageModule,
        NgbModule], exports: [DropdownSubmenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LabelModule {
    static { this.ɵfac = function LabelModule_Factory(t) { return new (t || LabelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LabelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LabelModule, [{
        type: NgModule,
        args: [{
                declarations: [LabelComponent],
                exports: [
                    LabelComponent
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LabelModule, { declarations: [LabelComponent], imports: [CommonModule], exports: [LabelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DropdownButtonModule {
    static { this.ɵfac = function DropdownButtonModule_Factory(t) { return new (t || DropdownButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DropdownButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgbDropdownModule,
            ImageModule,
            DropdownSubmenuModule,
            LabelModule,
            NgbTooltipModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [DropdownButtonComponent],
                exports: [
                    DropdownButtonComponent
                ],
                imports: [
                    CommonModule,
                    NgbDropdownModule,
                    ImageModule,
                    DropdownSubmenuModule,
                    LabelModule,
                    NgbTooltipModule,
                    TruncatePipe
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DropdownButtonModule, { declarations: [DropdownButtonComponent], imports: [CommonModule,
        NgbDropdownModule,
        ImageModule,
        DropdownSubmenuModule,
        LabelModule,
        NgbTooltipModule,
        TruncatePipe], exports: [DropdownButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ButtonModule {
    static { this.ɵfac = function ButtonModule_Factory(t) { return new (t || ButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule,
            LabelModule,
            NgbTooltipModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [ButtonComponent],
                exports: [ButtonComponent],
                imports: [
                    CommonModule,
                    ImageModule,
                    LabelModule,
                    NgbTooltipModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ButtonModule, { declarations: [ButtonComponent], imports: [CommonModule,
        ImageModule,
        LabelModule,
        NgbTooltipModule], exports: [ButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GroupedButtonModule {
    static { this.ɵfac = function GroupedButtonModule_Factory(t) { return new (t || GroupedButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GroupedButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupedButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [GroupedButtonComponent],
                exports: [
                    GroupedButtonComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(GroupedButtonModule, { declarations: [GroupedButtonComponent], imports: [CommonModule,
        ButtonModule], exports: [GroupedButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ButtonGroupModule {
    static { this.ɵfac = function ButtonGroupModule_Factory(t) { return new (t || ButtonGroupModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ButtonGroupModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            DropdownButtonModule,
            GroupedButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonGroupModule, [{
        type: NgModule,
        args: [{
                declarations: [ButtonGroupComponent],
                exports: [
                    ButtonGroupComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    DropdownButtonModule,
                    GroupedButtonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ButtonGroupModule, { declarations: [ButtonGroupComponent], imports: [CommonModule,
        ButtonModule,
        DropdownButtonModule,
        GroupedButtonModule], exports: [ButtonGroupComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DynamicLabelModule {
    static { this.ɵfac = function DynamicLabelModule_Factory(t) { return new (t || DynamicLabelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DynamicLabelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DynamicLabelModule, [{
        type: NgModule,
        args: [{
                declarations: [DynamicLabelComponent],
                exports: [
                    DynamicLabelComponent
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DynamicLabelModule, { declarations: [DynamicLabelComponent], imports: [CommonModule], exports: [DynamicLabelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InlineLoadingSpinnerModule {
    static { this.ɵfac = function InlineLoadingSpinnerModule_Factory(t) { return new (t || InlineLoadingSpinnerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: InlineLoadingSpinnerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InlineLoadingSpinnerModule, [{
        type: NgModule,
        args: [{
                declarations: [InlineLoadingSpinnerComponent],
                exports: [InlineLoadingSpinnerComponent],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(InlineLoadingSpinnerModule, { declarations: [InlineLoadingSpinnerComponent], imports: [CommonModule], exports: [InlineLoadingSpinnerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ActionGroupMenuModule {
    static { this.ɵfac = function ActionGroupMenuModule_Factory(t) { return new (t || ActionGroupMenuModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ActionGroupMenuModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule,
            ButtonModule,
            ButtonGroupModule,
            LabelModule,
            DynamicLabelModule,
            InlineLoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionGroupMenuModule, [{
        type: NgModule,
        args: [{
                declarations: [ActionGroupMenuComponent],
                exports: [ActionGroupMenuComponent],
                imports: [
                    CommonModule,
                    ImageModule,
                    ButtonModule,
                    ButtonGroupModule,
                    LabelModule,
                    DynamicLabelModule,
                    InlineLoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ActionGroupMenuModule, { declarations: [ActionGroupMenuComponent], imports: [CommonModule,
        ImageModule,
        ButtonModule,
        ButtonGroupModule,
        LabelModule,
        DynamicLabelModule,
        InlineLoadingSpinnerModule], exports: [ActionGroupMenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function BulkActionMenuComponent_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 17);
    i0.ɵɵelementContainerEnd();
} }
class BulkActionMenuComponent {
    constructor(languageStore) {
        this.languageStore = languageStore;
        this.subs = [];
        this.status = SelectionStatus.NONE;
        this.count = 0;
        this.SelectionStatus = SelectionStatus;
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
        this.count = 0;
        this.status = SelectionStatus.NONE;
    }
    ngOnInit() {
        this.subs = [];
        this.subs.push(this.selectionSource.getSelectionStatus().subscribe(status => this.status = status));
        this.subs.push(this.selectionSource.getSelectedCount().subscribe(count => this.count = count));
        this.subs.push(this.actionSource.getBulkActions().subscribe(actions => {
            const dropdownConfig = {
                labelKey: 'LBL_BULK_ACTION_BUTTON_LABEL',
                klass: ['bulk-action-button', 'btn', 'btn-sm'],
                wrapperKlass: ['bulk-action-group', 'float-left'],
                items: []
            };
            const dropdownSmallConfig = {
                labelKey: 'LBL_ACTION',
                klass: ['bulk-action-button', 'btn', 'btn-sm'],
                wrapperKlass: ['bulk-action-group', 'float-left'],
                items: []
            };
            Object.keys(actions).forEach(actionKey => {
                const action = actions[actionKey];
                dropdownConfig.items.push({
                    labelKey: action.labelKey ?? '',
                    klass: [`${actionKey}-bulk-action`],
                    onClick: () => {
                        this.actionSource.executeBulkAction(action.key);
                    }
                });
                dropdownSmallConfig.items.push({
                    labelKey: action.labelKey ?? '',
                    klass: [`${actionKey}-bulk-action`],
                    onClick: () => {
                        this.actionSource.executeBulkAction(action.key);
                    }
                });
            });
            this.dropdownConfig = dropdownConfig;
            this.dropdownSmallConfig = dropdownSmallConfig;
        }));
    }
    selectPage() {
        this.selectionSource.updateSelection(SelectionStatus.PAGE);
    }
    selectAll() {
        this.selectionSource.updateSelection(SelectionStatus.ALL);
    }
    deselectAll() {
        this.selectionSource.updateSelection(SelectionStatus.NONE);
    }
    toggleSelection(status) {
        if (status === SelectionStatus.ALL) {
            this.selectionSource.updateSelection(SelectionStatus.NONE);
            return;
        }
        this.selectionSource.updateSelection(SelectionStatus.ALL);
    }
    static { this.ɵfac = function BulkActionMenuComponent_Factory(t) { return new (t || BulkActionMenuComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BulkActionMenuComponent, selectors: [["scrm-bulk-action-menu"]], inputs: { selectionSource: "selectionSource", actionSource: "actionSource" }, decls: 18, vars: 8, consts: [[1, "bulk-action", "d-flex"], ["ngbDropdown", "", 1, "dropdown", "select-action-group"], ["type", "button", "ngbDropdownToggle", "", "aria-haspopup", "true", "aria-expanded", "false", "aria-hidden", "true", "aria-label", "Select Action Menu", 1, "bulk-action-button", "dropdown-toggle", "btn", "btn-sm"], [1, "checkbox-container"], ["type", "checkbox", "aria-hidden", "true", 3, "checked", "indeterminate", "change"], [1, "checkmark"], [1, "bulk-action-selected-number"], [4, "ngIf"], ["ngbDropdownMenu", "", "aria-hidden", "true", 1, "dropdown-menu"], [1, "dropdown-item", "select-all", 3, "click"], ["labelKey", "LBL_LISTVIEW_OPTION_ENTIRE"], [1, "dropdown-item", "select-page", 3, "click"], ["labelKey", "LBL_LISTVIEW_OPTION_CURRENT"], [1, "dropdown-item", "deselect-all", 3, "click"], ["labelKey", "LBL_LISTVIEW_NONE"], [1, "d-block", "d-sm-none", 3, "disabled", "config"], [1, "d-none", "d-sm-block", 3, "disabled", "config"], ["labelKey", "LBL_LISTVIEW_SELECTED_OBJECTS", 1, "d-none", "d-sm-inline"]], template: function BulkActionMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "button", 2)(3, "label", 3)(4, "input", 4);
            i0.ɵɵlistener("change", function BulkActionMenuComponent_Template_input_change_4_listener() { return ctx.toggleSelection(ctx.status); });
            i0.ɵɵelementEnd();
            i0.ɵɵelement(5, "span", 5);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "span", 6);
            i0.ɵɵtemplate(7, BulkActionMenuComponent_ng_container_7_Template, 2, 0, "ng-container", 7);
            i0.ɵɵtext(8);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(9, "div", 8)(10, "a", 9);
            i0.ɵɵlistener("click", function BulkActionMenuComponent_Template_a_click_10_listener() { return ctx.selectAll(); });
            i0.ɵɵelement(11, "scrm-label", 10);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(12, "a", 11);
            i0.ɵɵlistener("click", function BulkActionMenuComponent_Template_a_click_12_listener() { return ctx.selectPage(); });
            i0.ɵɵelement(13, "scrm-label", 12);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(14, "a", 13);
            i0.ɵɵlistener("click", function BulkActionMenuComponent_Template_a_click_14_listener() { return ctx.deselectAll(); });
            i0.ɵɵelement(15, "scrm-label", 14);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(16, "scrm-dropdown-button", 15)(17, "scrm-dropdown-button", 16);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("checked", ctx.status === "ALL")("indeterminate", ctx.status === "SOME" || ctx.status === "PAGE");
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.count > 0);
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate1(" ", ctx.count > 0 ? ctx.count : "", " ");
            i0.ɵɵadvance(8);
            i0.ɵɵproperty("disabled", ctx.count < 1)("config", ctx.dropdownSmallConfig);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("disabled", ctx.count < 1)("config", ctx.dropdownConfig);
        } }, dependencies: [i2.NgIf, i3$1.NgbDropdown, i3$1.NgbDropdownToggle, i3$1.NgbDropdownMenu, DropdownButtonComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BulkActionMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-bulk-action-menu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"bulk-action d-flex\">\n    <div ngbDropdown class=\"dropdown select-action-group\">\n        <button class=\"bulk-action-button dropdown-toggle btn btn-sm\"\n                type=\"button\"\n                ngbDropdownToggle\n                aria-haspopup=\"true\"\n                aria-expanded=\"false\"\n                aria-hidden=\"true\"\n                aria-label=\"Select Action Menu\">\n            <label class=\"checkbox-container\">\n                <input type=\"checkbox\"\n                       [checked]=\"status === 'ALL'\"\n                       [indeterminate]=\"status === 'SOME' || status === 'PAGE'\"\n                       (change)=\"toggleSelection(status)\"\n                       aria-hidden=\"true\">\n                <span class=\"checkmark\"></span>\n            </label>\n            <span class=\"bulk-action-selected-number\">\n                <ng-container *ngIf=\"count > 0\"> <scrm-label class=\"d-none d-sm-inline\" labelKey=\"LBL_LISTVIEW_SELECTED_OBJECTS\"></scrm-label></ng-container> {{count > 0 ? count : ''}}\n            </span>\n        </button>\n        <div class=\"dropdown-menu\"\n             ngbDropdownMenu\n             aria-hidden=\"true\">\n            <a class=\"dropdown-item select-all\" (click)=\"selectAll()\">\n                <scrm-label labelKey=\"LBL_LISTVIEW_OPTION_ENTIRE\"></scrm-label>\n            </a>\n            <a class=\"dropdown-item select-page\" (click)=\"selectPage()\">\n                <scrm-label labelKey=\"LBL_LISTVIEW_OPTION_CURRENT\"></scrm-label>\n            </a>\n            <a class=\"dropdown-item deselect-all\" (click)=\"deselectAll()\">\n                <scrm-label labelKey=\"LBL_LISTVIEW_NONE\"></scrm-label>\n            </a>\n        </div>\n    </div>\n    <scrm-dropdown-button class=\"d-block d-sm-none\"\n                          [disabled]=\"count < 1\"\n                          [config]=\"dropdownSmallConfig\">\n    </scrm-dropdown-button>\n    <scrm-dropdown-button class=\"d-none d-sm-block\"\n                          [disabled]=\"count < 1\"\n                          [config]=\"dropdownConfig\">\n    </scrm-dropdown-button>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { selectionSource: [{
            type: Input
        }], actionSource: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BulkActionMenuModule {
    static { this.ɵfac = function BulkActionMenuModule_Factory(t) { return new (t || BulkActionMenuModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BulkActionMenuModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgbModule,
            DropdownButtonModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BulkActionMenuModule, [{
        type: NgModule,
        args: [{
                declarations: [BulkActionMenuComponent],
                exports: [BulkActionMenuComponent],
                imports: [
                    CommonModule,
                    NgbModule,
                    DropdownButtonModule,
                    LabelModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BulkActionMenuModule, { declarations: [BulkActionMenuComponent], imports: [CommonModule,
        NgbModule,
        DropdownButtonModule,
        LabelModule], exports: [BulkActionMenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ButtonUtils {
    constructor() {
    }
    addOnClickPartial(button, partialInput) {
        const copy = { ...button };
        if (button && 'items' in copy) {
            const items = copy.items;
            copy.items = [];
            items.forEach(item => {
                copy.items.push(this.addOnClickPartial(item, partialInput));
            });
            return copy;
        }
        copy.onClick = copy.onClick && partial(copy.onClick, partialInput);
        return copy;
    }
    static { this.ɵfac = function ButtonUtils_Factory(t) { return new (t || ButtonUtils)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ButtonUtils, factory: ButtonUtils.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonUtils, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseChartComponent {
    constructor(elementRef, screenSize) {
        this.elementRef = elementRef;
        this.screenSize = screenSize;
        this.height = 300;
        this.view = signal([300, this.height]);
        this.subs = [];
    }
    onResize() {
        this.calculateView();
    }
    initResizeListener() {
        const resize$ = fromEvent(window, 'resize').pipe(tap(() => this.view.set([])), debounceTime(300));
        this.view.set([]);
        this.subs.push(resize$.pipe(debounceTime(50)).subscribe(() => {
            this.calculateView();
        }));
    }
    calculateView() {
        let width;
        const el = (this.elementRef && this.elementRef.nativeElement) || {};
        const parentEl = (el.parentElement && el.parentElement.parentElement) || {};
        const parentWidth = (parentEl && parentEl.offsetWidth) || 0;
        if (parentWidth > 0) {
            width = parentWidth;
        }
        else {
            width = window.innerWidth * 0.7;
            if (window.innerWidth > 990) {
                width = window.innerWidth * 0.23;
            }
        }
        this.view.set([width, this.height]);
    }
    static { this.ɵfac = function BaseChartComponent_Factory(t) { return new (t || BaseChartComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(ScreenSizeObserverService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseChartComponent, selectors: [["ng-component"]], inputs: { dataSource: "dataSource" }, decls: 0, vars: 0, template: function BaseChartComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseChartComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: i0.ElementRef }, { type: ScreenSizeObserverService }]; }, { dataSource: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseChartModule {
    static { this.ɵfac = function BaseChartModule_Factory(t) { return new (t || BaseChartModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BaseChartModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseChartModule, [{
        type: NgModule,
        args: [{
                exports: [
                    BaseChartComponent,
                ],
                declarations: [
                    BaseChartComponent,
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BaseChartModule, { declarations: [BaseChartComponent], imports: [CommonModule], exports: [BaseChartComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ChartMessageAreaComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelement(1, "scrm-label", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r0.labelKey);
} }
class ChartMessageAreaComponent {
    constructor(language) {
        this.language = language;
        this.labelKey = '';
    }
    static { this.ɵfac = function ChartMessageAreaComponent_Factory(t) { return new (t || ChartMessageAreaComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ChartMessageAreaComponent, selectors: [["scrm-chart-message-area"]], inputs: { labelKey: "labelKey" }, decls: 2, vars: 1, consts: [[1, "d-flex", "mb-4", "mt-4", "justify-content-center"], ["class", "lead", 4, "ngIf"], [1, "lead"], [3, "labelKey"]], template: function ChartMessageAreaComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, ChartMessageAreaComponent_div_1_Template, 2, 1, "div", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.labelKey);
        } }, dependencies: [i2.NgIf, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartMessageAreaComponent, [{
        type: Component,
        args: [{ selector: 'scrm-chart-message-area', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"d-flex mb-4 mt-4 justify-content-center\">\n    <div *ngIf=\"labelKey\" class=\"lead\">\n        <scrm-label [labelKey]=\"labelKey\"></scrm-label>\n    </div>\n</div>\n\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { labelKey: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadingSpinnerComponent {
    constructor() {
        this.overlay = false;
    }
    static { this.ɵfac = function LoadingSpinnerComponent_Factory(t) { return new (t || LoadingSpinnerComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LoadingSpinnerComponent, selectors: [["scrm-loading-spinner"]], inputs: { overlay: "overlay" }, decls: 19, vars: 2, consts: [[1, "loading-spinner"], [1, "sk-cube-grid"], [1, "sk-cube", "sk-cube1", "sk-cube-primary"], [1, "sk-cube", "sk-cube2", "sk-cube-secondary"], [1, "sk-cube", "sk-cube3", "sk-cube-secondary"], [1, "sk-cube", "sk-cube4", "sk-cube-primary"], [1, "sk-cube", "sk-cube5", "sk-cube-secondary"], [1, "sk-cube", "sk-cube6", "sk-cube-secondary"], [1, "sk-cube", "sk-cube7", "sk-cube-primary"], [1, "sk-cube", "sk-cube8", "sk-cube-primary"], [1, "sk-cube", "sk-cube9", "sk-cube-primary"]], template: function LoadingSpinnerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div")(1, "div", 0)(2, "div", 1);
            i0.ɵɵelement(3, "div", 2)(4, "div", 2)(5, "div", 3)(6, "div", 4)(7, "div", 5)(8, "div", 5)(9, "div", 6)(10, "div", 7)(11, "div", 8)(12, "div", 8)(13, "div", 9)(14, "div", 10)(15, "div", 8)(16, "div", 8)(17, "div", 9)(18, "div", 10);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵclassProp("overlay", ctx.overlay);
        } }, styles: [".sk-cube-grid[_ngcontent-%COMP%]{width:6.25em;height:6.25em}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube[_ngcontent-%COMP%]{width:25%;height:25%;float:left;animation:_ngcontent-%COMP%_sk-cubeGridScaleDelay 1.3s infinite ease-in-out}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube1[_ngcontent-%COMP%]{animation-delay:.2s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube2[_ngcontent-%COMP%]{animation-delay:.3s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube3[_ngcontent-%COMP%]{animation-delay:.4s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube4[_ngcontent-%COMP%]{animation-delay:.1s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube5[_ngcontent-%COMP%]{animation-delay:.2s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube6[_ngcontent-%COMP%]{animation-delay:.3s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube7[_ngcontent-%COMP%]{animation-delay:0s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube8[_ngcontent-%COMP%]{animation-delay:.1s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube9[_ngcontent-%COMP%]{animation-delay:.2s}@keyframes _ngcontent-%COMP%_sk-cubeGridScaleDelay{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}"] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadingSpinnerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-loading-spinner', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div [class.overlay]=\"overlay\">\n    <div class=\"loading-spinner\">\n        <div class=\"sk-cube-grid\">\n            <div class=\"sk-cube sk-cube1 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube1 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube2 sk-cube-secondary\"></div>\n            <div class=\"sk-cube sk-cube3 sk-cube-secondary\"></div>\n            <div class=\"sk-cube sk-cube4 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube4 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube5 sk-cube-secondary\"></div>\n            <div class=\"sk-cube sk-cube6 sk-cube-secondary\"></div>\n            <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube8 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube9 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube8 sk-cube-primary\"></div>\n            <div class=\"sk-cube sk-cube9 sk-cube-primary\"></div>\n        </div>\n    </div>\n</div>\n\n", styles: [".sk-cube-grid{width:6.25em;height:6.25em}.sk-cube-grid .sk-cube{width:25%;height:25%;float:left;animation:sk-cubeGridScaleDelay 1.3s infinite ease-in-out}.sk-cube-grid .sk-cube1{animation-delay:.2s}.sk-cube-grid .sk-cube2{animation-delay:.3s}.sk-cube-grid .sk-cube3{animation-delay:.4s}.sk-cube-grid .sk-cube4{animation-delay:.1s}.sk-cube-grid .sk-cube5{animation-delay:.2s}.sk-cube-grid .sk-cube6{animation-delay:.3s}.sk-cube-grid .sk-cube7{animation-delay:0s}.sk-cube-grid .sk-cube8{animation-delay:.1s}.sk-cube-grid .sk-cube9{animation-delay:.2s}@keyframes sk-cubeGridScaleDelay{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}\n"] }]
    }], function () { return []; }, { overlay: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function PieGridChartComponent_scrm_chart_message_area_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart-message-area", 3);
} }
function PieGridChartComponent_ng_container_1_ngx_charts_pie_grid_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ngx-charts-pie-grid", 5);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("animations", false)("view", ctx_r3.view())("scheme", ctx_r3.scheme)("minWidth", ctx_r3.minWidth)("label", ctx_r3.language.getFieldLabel(ctx_r3.label))("results", ctx_r3.results);
} }
function PieGridChartComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, PieGridChartComponent_ng_container_1_ngx_charts_pie_grid_1_Template, 1, 6, "ngx-charts-pie-grid", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.results && ctx_r1.results.length > 0);
} }
function PieGridChartComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-loading-spinner");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵclassProp("m-5", true);
} }
class PieGridChartComponent extends BaseChartComponent {
    constructor(language, elementRef, screenSize) {
        super(elementRef, screenSize);
        this.language = language;
        this.elementRef = elementRef;
        this.screenSize = screenSize;
        this.height = 700;
        this.minWidth = 100;
    }
    ngOnInit() {
        if (this.dataSource.options.height) {
            this.height = this.dataSource.options.height;
        }
        if (this?.dataSource?.options?.minWidth) {
            this.minWidth = this.dataSource.options.minWidth;
        }
        this.initResizeListener();
        this.subs.push(this.dataSource.getResults().pipe(debounceTime(500)).subscribe(value => {
            this.parseResults(value);
            this.calculateHeightBasedOnResults();
            this.calculateView();
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    get scheme() {
        return this.dataSource.options.scheme || 'picnic';
    }
    get label() {
        return this.dataSource.options.label || '';
    }
    onResize() {
        this.calculateHeightBasedOnResults();
        this.calculateView();
    }
    calculateHeightBasedOnResults() {
        if (this.results && this.results.length) {
            const perRow = Math.floor(this.view()[0] / 170);
            this.height = (Math.floor(this.results.length / perRow) * 200);
        }
        else {
            this.height = 50;
        }
    }
    parseResults(value) {
        this.results = [];
        if (value.singleSeries && value.singleSeries.length) {
            value.singleSeries.forEach(entry => {
                const parsedValue = parseFloat('' + entry.value);
                if (!parsedValue) {
                    this.results.push(entry);
                    return;
                }
                this.results.push({
                    name: entry.name,
                    value: parsedValue
                });
            });
        }
    }
    calculateView() {
        let width;
        const el = (this.elementRef && this.elementRef.nativeElement) || {};
        const parentEl = (el.parentElement && el.parentElement.parentElement) || {};
        const parentWidth = (parentEl && parentEl.offsetWidth) || 0;
        if (parentWidth > 0) {
            width = parentWidth;
        }
        else {
            width = window.innerWidth * 0.7;
            if (window.innerWidth > 990) {
                width = window.innerWidth * 0.23;
            }
        }
        if (width > 239) {
            this.view.set([width, this.height]);
            return;
        }
        this.view.set([width, 800]);
    }
    static { this.ɵfac = function PieGridChartComponent_Factory(t) { return new (t || PieGridChartComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(ScreenSizeObserverService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PieGridChartComponent, selectors: [["scrm-pie-grid-chart"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 3, consts: [["labelKey", "LBL_NO_DATA", 4, "ngIf"], [4, "ngIf"], ["class", "chart-loading", 3, "m-5", 4, "ngIf"], ["labelKey", "LBL_NO_DATA"], [3, "animations", "view", "scheme", "minWidth", "label", "results", 4, "ngIf"], [3, "animations", "view", "scheme", "minWidth", "label", "results"], [1, "chart-loading"]], template: function PieGridChartComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, PieGridChartComponent_scrm_chart_message_area_0_Template, 1, 0, "scrm-chart-message-area", 0);
            i0.ɵɵtemplate(1, PieGridChartComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            i0.ɵɵtemplate(2, PieGridChartComponent_div_2_Template, 2, 2, "div", 2);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.results || !ctx.results.length || ctx.results.length < 1);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.view().length);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.view().length && ctx.results && ctx.results.length > 0);
        } }, dependencies: [i2.NgIf, i3$2.PieGridComponent, ChartMessageAreaComponent, LoadingSpinnerComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PieGridChartComponent, [{
        type: Component,
        args: [{ selector: 'scrm-pie-grid-chart', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-chart-message-area *ngIf=\"!results || !results.length || results.length < 1\"\n                         labelKey=\"LBL_NO_DATA\"></scrm-chart-message-area>\n<ng-container *ngIf=\"view().length\">\n    <ngx-charts-pie-grid *ngIf=\"results && results.length > 0\"\n                         [animations]=\"false\"\n                         [view]=\"view()\"\n                         [scheme]=\"scheme\"\n                         [minWidth]=\"minWidth\"\n                         [label]=\"language.getFieldLabel(label)\"\n                         [results]=\"results\">\n    </ngx-charts-pie-grid>\n</ng-container>\n<div *ngIf=\"!view().length && results && results.length > 0\" [class.m-5]=\"true\" class=\"chart-loading\">\n    <scrm-loading-spinner></scrm-loading-spinner>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: i0.ElementRef }, { type: ScreenSizeObserverService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function VerticalBarChartComponent_scrm_chart_message_area_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart-message-area", 3);
} }
function VerticalBarChartComponent_ng_container_1_ngx_charts_bar_vertical_1_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const model_r6 = ctx.model;
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(model_r6.name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r5.formatTooltipValue(model_r6.value));
} }
function VerticalBarChartComponent_ng_container_1_ngx_charts_bar_vertical_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ngx-charts-bar-vertical", 5);
    i0.ɵɵtemplate(1, VerticalBarChartComponent_ng_container_1_ngx_charts_bar_vertical_1_ng_template_1_Template, 4, 2, "ng-template", null, 6, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("animations", false)("results", ctx_r3.results)("view", ctx_r3.view())("scheme", ctx_r3.scheme)("gradient", ctx_r3.gradient)("xAxis", ctx_r3.xAxis)("yAxis", ctx_r3.yAxis)("legend", ctx_r3.legend)("legendPosition", "below")("showXAxisLabel", ctx_r3.showXAxisLabel)("showYAxisLabel", ctx_r3.showYAxisLabel)("xAxisLabel", ctx_r3.xAxisLabel)("yAxisLabel", ctx_r3.yAxisLabel)("yAxisTickFormatting", ctx_r3.yAxisTickFormatting);
} }
function VerticalBarChartComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, VerticalBarChartComponent_ng_container_1_ngx_charts_bar_vertical_1_Template, 3, 14, "ngx-charts-bar-vertical", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.results && ctx_r1.results.length > 0);
} }
function VerticalBarChartComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵelement(1, "scrm-loading-spinner");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵclassProp("m-5", true);
} }
class VerticalBarChartComponent extends BaseChartComponent {
    constructor(elementRef, screenSize) {
        super(elementRef, screenSize);
        this.elementRef = elementRef;
        this.screenSize = screenSize;
    }
    ngOnInit() {
        if (this.dataSource.options.height) {
            this.height = this.dataSource.options.height;
        }
        this.initResizeListener();
        this.subs.push(this.dataSource.getResults().pipe(debounceTime(500)).subscribe(value => {
            this.results = value.singleSeries;
            this.calculateView();
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    get scheme() {
        return this.dataSource.options.scheme || 'picnic';
    }
    get gradient() {
        return this.dataSource.options.gradient || false;
    }
    get xAxis() {
        return this.dataSource.options.xAxis || false;
    }
    get yAxis() {
        return !isFalse(this.dataSource.options.yAxis);
    }
    get legend() {
        return !isFalse(this.dataSource.options.legend);
    }
    get showXAxisLabel() {
        return this.dataSource.options.showXAxisLabel || false;
    }
    get showYAxisLabel() {
        return this.dataSource.options.showYAxisLabel || false;
    }
    get xAxisLabel() {
        return this.dataSource.options.xAxisLabel || '';
    }
    get yAxisLabel() {
        return this.dataSource.options.yAxisLabel || '';
    }
    get yAxisTickFormatting() {
        if (this.dataSource.options.yAxisTickFormatting) {
            return this.dataSource.tickFormatting;
        }
        return null;
    }
    formatTooltipValue(value) {
        if (!this.dataSource || !this.dataSource.tooltipFormatting) {
            return value;
        }
        return this.dataSource.tooltipFormatting(value);
    }
    static { this.ɵfac = function VerticalBarChartComponent_Factory(t) { return new (t || VerticalBarChartComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(ScreenSizeObserverService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VerticalBarChartComponent, selectors: [["scrm-vertical-bar-chart"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 3, consts: [["labelKey", "LBL_NO_DATA", 4, "ngIf"], [4, "ngIf"], ["class", "chart-loading", 3, "m-5", 4, "ngIf"], ["labelKey", "LBL_NO_DATA"], ["class", "vertical-bar-chart", 3, "animations", "results", "view", "scheme", "gradient", "xAxis", "yAxis", "legend", "legendPosition", "showXAxisLabel", "showYAxisLabel", "xAxisLabel", "yAxisLabel", "yAxisTickFormatting", 4, "ngIf"], [1, "vertical-bar-chart", 3, "animations", "results", "view", "scheme", "gradient", "xAxis", "yAxis", "legend", "legendPosition", "showXAxisLabel", "showYAxisLabel", "xAxisLabel", "yAxisLabel", "yAxisTickFormatting"], ["tooltipTemplate", ""], [1, "chart-loading"]], template: function VerticalBarChartComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, VerticalBarChartComponent_scrm_chart_message_area_0_Template, 1, 0, "scrm-chart-message-area", 0);
            i0.ɵɵtemplate(1, VerticalBarChartComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            i0.ɵɵtemplate(2, VerticalBarChartComponent_div_2_Template, 2, 2, "div", 2);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.results || !ctx.results.length || ctx.results.length < 1);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.view().length);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.view().length && ctx.results && ctx.results.length > 0);
        } }, dependencies: [i2.NgIf, i3$2.BarVerticalComponent, ChartMessageAreaComponent, LoadingSpinnerComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VerticalBarChartComponent, [{
        type: Component,
        args: [{ selector: 'scrm-vertical-bar-chart', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-chart-message-area *ngIf=\"!results || !results.length || results.length < 1\"\n                         labelKey=\"LBL_NO_DATA\"></scrm-chart-message-area>\n<ng-container *ngIf=\"view().length\">\n    <ngx-charts-bar-vertical *ngIf=\"results && results.length > 0\"\n                             class=\"vertical-bar-chart\"\n                             [animations]=\"false\"\n                             [results]=\"results\"\n                             [view]=\"view()\"\n                             [scheme]=\"scheme\"\n                             [gradient]=\"gradient\"\n                             [xAxis]=\"xAxis\"\n                             [yAxis]=\"yAxis\"\n                             [legend]=\"legend\"\n                             [legendPosition]=\"'below'\"\n                             [showXAxisLabel]=\"showXAxisLabel\"\n                             [showYAxisLabel]=\"showYAxisLabel\"\n                             [xAxisLabel]=\"xAxisLabel\"\n                             [yAxisLabel]=\"yAxisLabel\"\n                             [yAxisTickFormatting]=\"yAxisTickFormatting\">\n        <ng-template #tooltipTemplate let-model=\"model\">\n            <div>{{model.name}}</div>\n            <div>{{ formatTooltipValue(model.value) }}</div>\n        </ng-template>\n    </ngx-charts-bar-vertical>\n</ng-container>\n<div *ngIf=\"!view().length && results && results.length > 0\" [class.m-5]=\"true\" class=\"chart-loading\">\n    <scrm-loading-spinner></scrm-loading-spinner>\n</div>\n\n\n" }]
    }], function () { return [{ type: i0.ElementRef }, { type: ScreenSizeObserverService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChartMessageAreaModule {
    static { this.ɵfac = function ChartMessageAreaModule_Factory(t) { return new (t || ChartMessageAreaModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ChartMessageAreaModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartMessageAreaModule, [{
        type: NgModule,
        args: [{
                declarations: [ChartMessageAreaComponent],
                exports: [ChartMessageAreaComponent],
                imports: [
                    CommonModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ChartMessageAreaModule, { declarations: [ChartMessageAreaComponent], imports: [CommonModule,
        LabelModule], exports: [ChartMessageAreaComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadingSpinnerModule {
    static { this.ɵfac = function LoadingSpinnerModule_Factory(t) { return new (t || LoadingSpinnerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LoadingSpinnerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadingSpinnerModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    LoadingSpinnerComponent
                ],
                exports: [
                    LoadingSpinnerComponent
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LoadingSpinnerModule, { declarations: [LoadingSpinnerComponent], imports: [CommonModule], exports: [LoadingSpinnerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VerticalBarChartModule {
    static { this.ɵfac = function VerticalBarChartModule_Factory(t) { return new (t || VerticalBarChartModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: VerticalBarChartModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgxChartsModule,
            ChartMessageAreaModule,
            LoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VerticalBarChartModule, [{
        type: NgModule,
        args: [{
                declarations: [VerticalBarChartComponent],
                exports: [VerticalBarChartComponent],
                imports: [
                    CommonModule,
                    NgxChartsModule,
                    ChartMessageAreaModule,
                    LoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(VerticalBarChartModule, { declarations: [VerticalBarChartComponent], imports: [CommonModule,
        NgxChartsModule,
        ChartMessageAreaModule,
        LoadingSpinnerModule], exports: [VerticalBarChartComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PieGridChartModule {
    static { this.ɵfac = function PieGridChartModule_Factory(t) { return new (t || PieGridChartModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PieGridChartModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgxChartsModule,
            ChartMessageAreaModule,
            LoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PieGridChartModule, [{
        type: NgModule,
        args: [{
                declarations: [PieGridChartComponent],
                exports: [PieGridChartComponent],
                imports: [
                    CommonModule,
                    NgxChartsModule,
                    ChartMessageAreaModule,
                    LoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PieGridChartModule, { declarations: [PieGridChartComponent], imports: [CommonModule,
        NgxChartsModule,
        ChartMessageAreaModule,
        LoadingSpinnerModule], exports: [PieGridChartComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LineChartComponent_scrm_chart_message_area_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart-message-area", 3);
} }
function LineChartComponent_ng_container_1_ngx_charts_line_chart_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ngx-charts-line-chart", 5);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("animations", false)("results", ctx_r3.results)("view", ctx_r3.view())("scheme", ctx_r3.scheme)("gradient", ctx_r3.gradient)("xAxis", ctx_r3.xAxis)("yAxis", ctx_r3.yAxis)("legend", ctx_r3.legend)("xScaleMin", ctx_r3.xScaleMin)("xScaleMax", ctx_r3.xScaleMax)("xAxisTicks", ctx_r3.xAxisTicks)("showXAxisLabel", ctx_r3.showXAxisLabel)("showYAxisLabel", ctx_r3.showYAxisLabel)("xAxisLabel", ctx_r3.xAxisLabel)("legendPosition", "below")("autoScale", true)("yAxisTickFormatting", ctx_r3.yAxisTickFormatting)("xAxisTickFormatting", ctx_r3.xAxisTickFormatting)("tooltipDisabled", ctx_r3.tooltipDisabled)("yAxisLabel", ctx_r3.yAxisLabel);
} }
function LineChartComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LineChartComponent_ng_container_1_ngx_charts_line_chart_1_Template, 1, 20, "ngx-charts-line-chart", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.results && ctx_r1.results.length > 0);
} }
function LineChartComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-loading-spinner");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵclassProp("m-5", true);
} }
class LineChartComponent extends BaseChartComponent {
    constructor(elementRef, screenSize) {
        super(elementRef, screenSize);
        this.elementRef = elementRef;
        this.screenSize = screenSize;
    }
    ngOnInit() {
        if (this.dataSource.options.height) {
            this.height = this.dataSource.options.height;
        }
        this.initResizeListener();
        this.subs.push(this.dataSource.getResults().subscribe(value => {
            this.results = value.multiSeries;
            this.calculateView();
        }));
        this.scheme = this.getScheme();
        this.gradient = this.getGradient();
        this.xAxis = this.getXAxis();
        this.yAxis = this.getYAxis();
        this.legend = this.getLegend();
        this.xScaleMin = this.getXScaleMin();
        this.xScaleMax = this.getXScaleMax();
        this.xAxisTicks = this.getXAxisTicks();
        this.showXAxisLabel = this.getShowXAxisLabel();
        this.showYAxisLabel = this.getShowYAxisLabel();
        this.xAxisLabel = this.getXAxisLabel();
        this.yAxisLabel = this.getYAxisLabel();
        this.yAxisTickFormatting = this.getYAxisTickFormatting();
        this.xAxisTickFormatting = this.getXAxisTickFormatting();
        this.tooltipDisabled = this.getTooltipDisabled();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getScheme() {
        return this.dataSource.options.scheme || 'picnic';
    }
    getGradient() {
        return this.dataSource.options.gradient || false;
    }
    getXAxis() {
        return !isFalse(this.dataSource.options.xAxis);
    }
    getYAxis() {
        return !isFalse(this.dataSource.options.yAxis);
    }
    getLegend() {
        return !isFalse(this.dataSource.options.legend);
    }
    getXScaleMin() {
        return this.dataSource.options.xScaleMin || null;
    }
    getXScaleMax() {
        return this.dataSource.options.xScaleMax || null;
    }
    getXAxisTicks() {
        return this.dataSource.options.xAxisTicks || null;
    }
    getShowXAxisLabel() {
        return !isFalse(this.dataSource.options.showXAxisLabel);
    }
    getShowYAxisLabel() {
        return this.dataSource.options.showYAxisLabel || false;
    }
    getXAxisLabel() {
        return this.dataSource.options.xAxisLabel || '';
    }
    getYAxisLabel() {
        return this.dataSource.options.yAxisLabel || '';
    }
    getYAxisTickFormatting() {
        if (!this.dataSource.options.yAxisTickFormatting) {
            return null;
        }
        return this.dataSource.tickFormatting || null;
    }
    getXAxisTickFormatting() {
        if (!this.dataSource.options.xAxisTickFormatting) {
            return null;
        }
        return this.dataSource.tickFormatting || null;
    }
    getTooltipDisabled() {
        return this.dataSource.options.tooltipDisabled || false;
    }
    static { this.ɵfac = function LineChartComponent_Factory(t) { return new (t || LineChartComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(ScreenSizeObserverService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LineChartComponent, selectors: [["scrm-line-chart"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 3, consts: [["labelKey", "LBL_NO_DATA", 4, "ngIf"], [4, "ngIf"], ["class", "chart-loading", 3, "m-5", 4, "ngIf"], ["labelKey", "LBL_NO_DATA"], ["class", "line-chart", 3, "animations", "results", "view", "scheme", "gradient", "xAxis", "yAxis", "legend", "xScaleMin", "xScaleMax", "xAxisTicks", "showXAxisLabel", "showYAxisLabel", "xAxisLabel", "legendPosition", "autoScale", "yAxisTickFormatting", "xAxisTickFormatting", "tooltipDisabled", "yAxisLabel", 4, "ngIf"], [1, "line-chart", 3, "animations", "results", "view", "scheme", "gradient", "xAxis", "yAxis", "legend", "xScaleMin", "xScaleMax", "xAxisTicks", "showXAxisLabel", "showYAxisLabel", "xAxisLabel", "legendPosition", "autoScale", "yAxisTickFormatting", "xAxisTickFormatting", "tooltipDisabled", "yAxisLabel"], [1, "chart-loading"]], template: function LineChartComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LineChartComponent_scrm_chart_message_area_0_Template, 1, 0, "scrm-chart-message-area", 0);
            i0.ɵɵtemplate(1, LineChartComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            i0.ɵɵtemplate(2, LineChartComponent_div_2_Template, 2, 2, "div", 2);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.results || !ctx.results.length || ctx.results.length < 1);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.view().length);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.view().length && ctx.results && ctx.results.length > 0);
        } }, dependencies: [i2.NgIf, i3$2.LineChartComponent, ChartMessageAreaComponent, LoadingSpinnerComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineChartComponent, [{
        type: Component,
        args: [{ selector: 'scrm-line-chart', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-chart-message-area *ngIf=\"!results || !results.length || results.length < 1\"\n                         labelKey=\"LBL_NO_DATA\"></scrm-chart-message-area>\n<ng-container *ngIf=\"view().length\">\n    <ngx-charts-line-chart *ngIf=\"results && results.length > 0\"\n                           class=\"line-chart\"\n                           [animations]=\"false\"\n                           [results]=\"results\"\n                           [view]=\"view()\"\n                           [scheme]=\"scheme\"\n                           [gradient]=\"gradient\"\n                           [xAxis]=\"xAxis\"\n                           [yAxis]=\"yAxis\"\n                           [legend]=\"legend\"\n                           [xScaleMin]=\"xScaleMin\"\n                           [xScaleMax]=\"xScaleMax\"\n                           [xAxisTicks]=\"xAxisTicks\"\n                           [showXAxisLabel]=\"showXAxisLabel\"\n                           [showYAxisLabel]=\"showYAxisLabel\"\n                           [xAxisLabel]=\"xAxisLabel\"\n                           [legendPosition]=\"'below'\"\n                           [autoScale]=\"true\"\n                           [yAxisTickFormatting]=\"yAxisTickFormatting\"\n                           [xAxisTickFormatting]=\"xAxisTickFormatting\"\n                           [tooltipDisabled]=\"tooltipDisabled\"\n                           [yAxisLabel]=\"yAxisLabel\">\n    </ngx-charts-line-chart>\n</ng-container>\n<div *ngIf=\"!view().length && results && results.length > 0\" [class.m-5]=\"true\" class=\"chart-loading\">\n    <scrm-loading-spinner></scrm-loading-spinner>\n</div>\n" }]
    }], function () { return [{ type: i0.ElementRef }, { type: ScreenSizeObserverService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineChartModule {
    static { this.ɵfac = function LineChartModule_Factory(t) { return new (t || LineChartModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LineChartModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgxChartsModule,
            ChartMessageAreaModule,
            LoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineChartModule, [{
        type: NgModule,
        args: [{
                declarations: [LineChartComponent],
                exports: [LineChartComponent],
                imports: [
                    CommonModule,
                    NgxChartsModule,
                    ChartMessageAreaModule,
                    LoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LineChartModule, { declarations: [LineChartComponent], imports: [CommonModule,
        NgxChartsModule,
        ChartMessageAreaModule,
        LoadingSpinnerModule], exports: [LineChartComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const chartModules = [
    LineChartModule,
    PieGridChartModule,
    VerticalBarChartModule
];
const chartTypeMap = {
    'line-chart': LineChartComponent,
    'pie-grid': PieGridChartComponent,
    'vertical-bar': VerticalBarChartComponent
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChartRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        Object.keys(chartTypeMap).forEach(key => {
            this.register('default', key, chartTypeMap[key]);
        });
    }
    static { this.ɵfac = function ChartRegistry_Factory(t) { return new (t || ChartRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ChartRegistry, factory: ChartRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ChartComponent_scrm_chart_message_area_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart-message-area", 2);
} }
const _c0$K = function (a0) { return { "dataSource": a0 }; };
function ChartComponent_ndc_dynamic_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 3);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r1.chartType)("ndcDynamicInputs", i0.ɵɵpureFunction1(2, _c0$K, ctx_r1.dataSource));
} }
class ChartComponent {
    constructor(registry) {
        this.registry = registry;
        this.dataSource = null;
    }
    get chartType() {
        return this.registry.get('default', this.type);
    }
    ngOnInit() {
    }
    isConfigured() {
        return !!(this.type && this.dataSource && this.chartType);
    }
    static { this.ɵfac = function ChartComponent_Factory(t) { return new (t || ChartComponent)(i0.ɵɵdirectiveInject(ChartRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ChartComponent, selectors: [["scrm-chart"]], inputs: { dataSource: "dataSource", type: "type" }, decls: 2, vars: 2, consts: [["labelKey", "LBL_BAD_CONFIG", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], ["labelKey", "LBL_BAD_CONFIG"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function ChartComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ChartComponent_scrm_chart_message_area_0_Template, 1, 0, "scrm-chart-message-area", 0);
            i0.ɵɵtemplate(1, ChartComponent_ndc_dynamic_1_Template, 1, 4, "ndc-dynamic", 1);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.isConfigured());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.isConfigured());
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent, ChartMessageAreaComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartComponent, [{
        type: Component,
        args: [{ selector: 'scrm-chart', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-chart-message-area *ngIf=\"!isConfigured()\" labelKey=\"LBL_BAD_CONFIG\"></scrm-chart-message-area>\n<ndc-dynamic *ngIf=\"isConfigured()\"\n             [ndcDynamicComponent]=\"chartType\"\n             [ndcDynamicInputs]=\"{'dataSource': dataSource}\">\n</ndc-dynamic>\n\n" }]
    }], function () { return [{ type: ChartRegistry }]; }, { dataSource: [{
            type: Input,
            args: ['dataSource']
        }], type: [{
            type: Input,
            args: ['type']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChartModule {
    static { this.ɵfac = function ChartModule_Factory(t) { return new (t || ChartModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ChartModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule, chartModules, DynamicModule,
            ChartMessageAreaModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartModule, [{
        type: NgModule,
        args: [{
                declarations: [ChartComponent],
                exports: [ChartComponent],
                imports: [
                    CommonModule,
                    ...chartModules,
                    DynamicModule,
                    ChartMessageAreaModule,
                ],
                schemas: [CUSTOM_ELEMENTS_SCHEMA]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ChartModule, { declarations: [ChartComponent], imports: [CommonModule, LineChartModule, PieGridChartModule, VerticalBarChartModule, DynamicModule,
        ChartMessageAreaModule], exports: [ChartComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function CloseButtonComponent_scrm_button_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "scrm-button", 1)(1, "span", 2);
    i0.ɵɵtext(2, "\u00D7");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("config", ctx_r0.getConfig());
} }
class CloseButtonComponent {
    constructor() {
        this.buttonClasses = ['close-button'];
    }
    getConfig() {
        const btn = Button.fromButton(this.config);
        btn.addClasses(this.buttonClasses);
        return btn;
    }
    static { this.ɵfac = function CloseButtonComponent_Factory(t) { return new (t || CloseButtonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CloseButtonComponent, selectors: [["scrm-close-button"]], inputs: { config: "config" }, decls: 1, vars: 1, consts: [[3, "config", 4, "ngIf"], [3, "config"], ["aria-hidden", "true"]], template: function CloseButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, CloseButtonComponent_scrm_button_0_Template, 3, 1, "scrm-button", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.config);
        } }, dependencies: [i2.NgIf, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CloseButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-close-button', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-button *ngIf=\"config\" [config]=\"getConfig()\">\n    <span aria-hidden=\"true\">&times;</span>\n</scrm-button>\n" }]
    }], function () { return []; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CloseButtonModule {
    static { this.ɵfac = function CloseButtonModule_Factory(t) { return new (t || CloseButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CloseButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CloseButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [CloseButtonComponent],
                exports: [
                    CloseButtonComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CloseButtonModule, { declarations: [CloseButtonComponent], imports: [CommonModule,
        ButtonModule], exports: [CloseButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ModalComponent_scrm_label_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-label", 3);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("labelKey", ctx_r0.titleKey);
} }
function ModalComponent_scrm_close_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-close-button", 4);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("config", ctx_r1.close);
} }
const _c0$J = [[["", "modal-body", ""]], [["", "modal-footer", ""]]];
const _c1$e = ["[modal-body]", "[modal-footer]"];
class ModalComponent {
    constructor() {
        this.klass = '';
        this.headerKlass = '';
        this.bodyKlass = '';
        this.footerKlass = '';
        this.titleKey = '';
        this.closable = false;
        this.close = {
            klass: ['btn', 'btn-outline-light', 'btn-sm']
        };
    }
    static { this.ɵfac = function ModalComponent_Factory(t) { return new (t || ModalComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ModalComponent, selectors: [["scrm-modal"]], inputs: { klass: "klass", headerKlass: "headerKlass", bodyKlass: "bodyKlass", footerKlass: "footerKlass", titleKey: "titleKey", closable: "closable", close: "close" }, ngContentSelectors: _c1$e, decls: 9, vars: 13, consts: [[1, "modal-title"], [3, "labelKey", 4, "ngIf"], [3, "config", 4, "ngIf"], [3, "labelKey"], [3, "config"]], template: function ModalComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$J);
            i0.ɵɵelementStart(0, "div")(1, "div")(2, "div", 0);
            i0.ɵɵtemplate(3, ModalComponent_scrm_label_3_Template, 1, 1, "scrm-label", 1);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(4, ModalComponent_scrm_close_button_4_Template, 1, 1, "scrm-close-button", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "div");
            i0.ɵɵprojection(6);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(7, "div");
            i0.ɵɵprojection(8, 1);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵclassMap(ctx.klass);
            i0.ɵɵadvance(1);
            i0.ɵɵclassMapInterpolate1("modal-header ", ctx.headerKlass, " d-flex align-items-center");
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.titleKey);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.closable);
            i0.ɵɵadvance(1);
            i0.ɵɵclassMapInterpolate1("modal-body ", ctx.bodyKlass, "");
            i0.ɵɵadvance(2);
            i0.ɵɵclassMapInterpolate1("modal-footer ", ctx.footerKlass, "");
        } }, dependencies: [i2.NgIf, CloseButtonComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModalComponent, [{
        type: Component,
        args: [{ selector: 'scrm-modal', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div [class]=\"klass\">\n    <div class=\"modal-header {{headerKlass}} d-flex align-items-center\">\n        <div class=\"modal-title\">\n            <scrm-label *ngIf=\"titleKey\" [labelKey]=\"titleKey\"></scrm-label>\n        </div>\n        <scrm-close-button *ngIf=\"closable\" [config]=\"close\"></scrm-close-button>\n    </div>\n\n    <div class=\"modal-body {{bodyKlass}}\">\n        <ng-content select=\"[modal-body]\"></ng-content>\n    </div>\n\n    <div class=\"modal-footer {{footerKlass}}\">\n        <ng-content select=\"[modal-footer]\"></ng-content>\n    </div>\n</div>\n" }]
    }], null, { klass: [{
            type: Input
        }], headerKlass: [{
            type: Input
        }], bodyKlass: [{
            type: Input
        }], footerKlass: [{
            type: Input
        }], titleKey: [{
            type: Input
        }], closable: [{
            type: Input
        }], close: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ColumnChooserComponent_div_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.getColumnLabel(item_r4.label), " ");
} }
function ColumnChooserComponent_div_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 17);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r5 = ctx.$implicit;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.getColumnLabel(item_r5.label), " ");
} }
const _c0$I = function (a0) { return [a0]; };
class ColumnChooserComponent {
    constructor(appState, languageStore, modal) {
        this.appState = appState;
        this.languageStore = languageStore;
        this.modal = modal;
        this.titleKey = 'LBL_COLUMN_SELECTOR_MODAL_TITLE';
    }
    drop(event) {
        if (event.previousContainer === event.container) {
            moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
        }
        else {
            transferArrayItem(event.previousContainer.data, event.container.data, event.previousIndex, event.currentIndex);
        }
    }
    getHeaderLabel() {
        return this.languageStore.getFieldLabel('LBL_COLUMN_SELECTOR_MODAL_TITLE');
    }
    getColumnLabel(label) {
        return this.languageStore.getFieldLabel(label, this.appState.getModule());
    }
    ngOnInit() {
        this.closeButtonIcon = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.modal.close({
                    type: 'close-button'
                });
            }
        };
        this.closeButton = {
            klass: ['btn', 'modal-button-cancel'],
            labelKey: 'LBL_COLUMN_SELECTOR_CLOSE_BUTTON',
            onClick: () => {
                this.modal.close({
                    type: 'close-button'
                });
            }
        };
        this.saveButton = {
            klass: ['btn', 'modal-button-save'],
            labelKey: 'LBL_COLUMN_SELECTOR_SAVE_BUTTON',
            onClick: () => {
                this.modal.close({
                    type: 'close-button',
                    displayed: this.displayed,
                    hidden: this.hidden
                });
            }
        };
    }
    static { this.ɵfac = function ColumnChooserComponent_Factory(t) { return new (t || ColumnChooserComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(i3$1.NgbActiveModal)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ColumnChooserComponent, selectors: [["scrm-columnchooser"]], inputs: { displayed: "displayed", hidden: "hidden" }, decls: 19, vars: 16, consts: [["klass", "column-chooser-modal", 3, "closable", "close", "title", "titleKey"], ["modal-body", ""], [1, "d-flex", "bd-highlight"], [1, "p-2", "flex-fill", "bd-highlight", "column-chooser-container"], [1, "column-chooser-title"], ["labelKey", "LBL_COLUMN_SELECTOR_DISPLAYED_COLS"], ["cdkDropList", "", 1, "column-chooser-list", 3, "cdkDropListData", "cdkDropListConnectedTo", "cdkDropListDropped"], ["displayedList", "cdkDropList"], ["class", "column-chooser-item column-displayed", "cdkDrag", "", 4, "ngFor", "ngForOf"], ["labelKey", "LBL_COLUMN_SELECTOR_HIDDEN_COLS"], ["hiddenList", "cdkDropList"], ["class", "column-chooser-item column-hidden", "cdkDrag", "", 4, "ngFor", "ngForOf"], ["modal-footer", ""], [1, "modal-buttons"], ["data-dismiss", "modal", 3, "config"], [3, "config"], ["cdkDrag", "", 1, "column-chooser-item", "column-displayed"], ["cdkDrag", "", 1, "column-chooser-item", "column-hidden"]], template: function ColumnChooserComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-modal", 0)(1, "div", 1)(2, "div", 2)(3, "div", 3)(4, "h2", 4);
            i0.ɵɵelement(5, "scrm-label", 5);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 6, 7);
            i0.ɵɵlistener("cdkDropListDropped", function ColumnChooserComponent_Template_div_cdkDropListDropped_6_listener($event) { return ctx.drop($event); });
            i0.ɵɵtemplate(8, ColumnChooserComponent_div_8_Template, 2, 1, "div", 8);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(9, "div", 3)(10, "h2", 4);
            i0.ɵɵelement(11, "scrm-label", 9);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(12, "div", 6, 10);
            i0.ɵɵlistener("cdkDropListDropped", function ColumnChooserComponent_Template_div_cdkDropListDropped_12_listener($event) { return ctx.drop($event); });
            i0.ɵɵtemplate(14, ColumnChooserComponent_div_14_Template, 2, 1, "div", 11);
            i0.ɵɵelementEnd()()()();
            i0.ɵɵelementStart(15, "div", 12)(16, "div", 13);
            i0.ɵɵelement(17, "scrm-button", 14)(18, "scrm-button", 15);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(7);
            const _r2 = i0.ɵɵreference(13);
            i0.ɵɵproperty("closable", true)("close", ctx.closeButtonIcon)("title", ctx.getHeaderLabel())("titleKey", ctx.titleKey);
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("cdkDropListData", ctx.displayed)("cdkDropListConnectedTo", i0.ɵɵpureFunction1(12, _c0$I, _r2));
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngForOf", ctx.displayed);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("cdkDropListData", ctx.hidden)("cdkDropListConnectedTo", i0.ɵɵpureFunction1(14, _c0$I, _r0));
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngForOf", ctx.hidden);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("config", ctx.closeButton);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.saveButton);
        } }, dependencies: [i2.NgForOf, i5.CdkDropList, i5.CdkDrag, ModalComponent, LabelComponent, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ColumnChooserComponent, [{
        type: Component,
        args: [{ selector: 'scrm-columnchooser', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<scrm-modal\n    [closable]=\"true\"\n    [close]=\"closeButtonIcon\"\n    [title]=\"getHeaderLabel()\"\n    [titleKey]=\"titleKey\"\n    klass=\"column-chooser-modal\">\n\n    <div modal-body>\n\n        <div class=\"d-flex bd-highlight\">\n            <div class=\"p-2 flex-fill bd-highlight column-chooser-container\">\n                <h2 class=\"column-chooser-title\">\n                    <scrm-label labelKey=\"LBL_COLUMN_SELECTOR_DISPLAYED_COLS\"></scrm-label>\n                </h2>\n\n                <div\n                    cdkDropList\n                    #displayedList=\"cdkDropList\"\n                    [cdkDropListData]=\"displayed\"\n                    [cdkDropListConnectedTo]=\"[hiddenList]\"\n                    class=\"column-chooser-list\"\n                    (cdkDropListDropped)=\"drop($event)\">\n                    <div class=\"column-chooser-item column-displayed\" *ngFor=\"let item of displayed\"\n                         cdkDrag>\n                        {{getColumnLabel(item.label)}}\n                    </div>\n                </div>\n            </div>\n            <div class=\"p-2 flex-fill bd-highlight column-chooser-container\">\n                <h2 class=\"column-chooser-title\">\n                    <scrm-label labelKey=\"LBL_COLUMN_SELECTOR_HIDDEN_COLS\"></scrm-label>\n                </h2>\n\n                <div\n                    cdkDropList\n                    #hiddenList=\"cdkDropList\"\n                    [cdkDropListData]=\"hidden\"\n                    [cdkDropListConnectedTo]=\"[displayedList]\"\n                    class=\"column-chooser-list\"\n                    (cdkDropListDropped)=\"drop($event)\">\n                    <div class=\"column-chooser-item column-hidden\" *ngFor=\"let item of hidden\" cdkDrag>\n                        {{getColumnLabel(item.label)}}\n                    </div>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <div modal-footer>\n        <div class=\"modal-buttons\">\n            <scrm-button data-dismiss=\"modal\" [config]=\"closeButton\"></scrm-button>\n            <scrm-button [config]=\"saveButton\"></scrm-button>\n        </div>\n    </div>\n\n</scrm-modal>\n" }]
    }], function () { return [{ type: AppStateStore }, { type: LanguageStore }, { type: i3$1.NgbActiveModal }]; }, { displayed: [{
            type: Input
        }], hidden: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModalModule {
    static { this.ɵfac = function ModalModule_Factory(t) { return new (t || ModalModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ModalModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AngularSvgIconModule,
            CloseButtonModule,
            LabelModule,
            NgbModalModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModalModule, [{
        type: NgModule,
        args: [{
                declarations: [ModalComponent],
                exports: [ModalComponent],
                imports: [
                    CommonModule,
                    AngularSvgIconModule,
                    CloseButtonModule,
                    LabelModule,
                    NgbModalModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ModalModule, { declarations: [ModalComponent], imports: [CommonModule,
        AngularSvgIconModule,
        CloseButtonModule,
        LabelModule,
        NgbModalModule], exports: [ModalComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ColumnChooserModule {
    static { this.ɵfac = function ColumnChooserModule_Factory(t) { return new (t || ColumnChooserModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ColumnChooserModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            DragDropModule,
            CloseButtonModule,
            ModalModule,
            LabelModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ColumnChooserModule, [{
        type: NgModule,
        args: [{
                declarations: [ColumnChooserComponent],
                exports: [ColumnChooserComponent],
                imports: [
                    CommonModule,
                    DragDropModule,
                    CloseButtonModule,
                    ModalModule,
                    LabelModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ColumnChooserModule, { declarations: [ColumnChooserComponent], imports: [CommonModule,
        DragDropModule,
        CloseButtonModule,
        ModalModule,
        LabelModule,
        ButtonModule], exports: [ColumnChooserComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldGridComponent {
    constructor(breakpointObserver) {
        this.breakpointObserver = breakpointObserver;
        this.special = false;
        this.actions = false;
        this.appendActions = false;
        this.labelDisplay = 'top';
        this.labelClass = {};
        this.inputClass = {};
        this.rowClass = {};
        this.colClass = {};
        this.colAlignItems = '';
        this.sizeMap = {
            handset: 1,
            tablet: 2,
            web: 3,
            wide: 4
        };
        this.baseColClass = {
            col: true,
            'form-group': true,
            'm-1': true
        };
        this.baseRowClass = {
            'form-row': true,
            'align-items-center': true
        };
        this.baseLabelClass = {
            'col-form-label-sm': true,
            'mb-0': true,
        };
        this.baseInputClass = {
            'form-control': true,
            'form-control-sm': true,
        };
        this.currentSize = 'web';
        this.subscriptions = [];
    }
    ngOnInit() {
        this.initScreenSizeObserver(this.breakpointObserver);
        this.buildGrid();
        this.colClass = {
            ...this.colClass,
            ...this.baseColClass
        };
        this.rowClass = {
            ...this.baseRowClass,
            ...this.rowClass
        };
        this.labelClass = {
            ...this.labelClass,
            ...this.baseLabelClass
        };
        this.inputClass = {
            ...this.inputClass,
            ...this.baseInputClass
        };
    }
    ngOnDestroy() {
        this.subscriptions.forEach(sub => sub.unsubscribe());
    }
    get colNumber() {
        const max = this.sizeMap[this.currentSize];
        if (this.maxColumns && max > this.maxColumns) {
            return this.maxColumns;
        }
        return max;
    }
    addSpecialSlots(grid) {
        if (!grid || grid.length === 0) {
            return;
        }
        const neededSlots = this.getNeededExtraSlots();
        if (neededSlots.length === 0) {
            return;
        }
        if (this.colNumber === 1) {
            neededSlots.reverse().forEach(type => {
                const newRow = {
                    cols: []
                };
                this.fillRow(newRow);
                grid.push(newRow);
                newRow.cols[0][type] = true;
            });
        }
        else if (this.appendActions === true) {
            const lastRow = grid[grid.length - 1];
            const place = this.colNumber - 1;
            neededSlots.forEach(type => {
                lastRow.cols[place][type] = true;
            });
        }
        else {
            const lastNeededCol = this.colNumber - neededSlots.length;
            let lastRow = grid[grid.length - 1];
            if (lastRow.cols[lastNeededCol].field) {
                lastRow = {
                    cols: []
                };
                this.fillRow(lastRow);
                grid.push(lastRow);
            }
            let place = this.colNumber - 1;
            neededSlots.forEach(type => {
                lastRow.cols[place][type] = true;
                place--;
            });
        }
    }
    getNeededExtraSlots() {
        const neededSlots = [];
        if (this.actions) {
            neededSlots.push('actionSlot');
        }
        if (this.special) {
            neededSlots.push('specialSlot');
        }
        return neededSlots;
    }
    fillRow(row) {
        const len = row.cols.length;
        for (let i = len; i < this.colNumber; i++) {
            row.cols.push({ field: { type: '', display: 'none' } });
        }
    }
    initScreenSizeObserver(breakpointObserver) {
        this.subscriptions.push(breakpointObserver.observe([
            Breakpoints.HandsetPortrait,
        ]).subscribe((result) => {
            if (result.matches) {
                this.currentSize = 'handset';
                this.buildGrid();
            }
        }));
        this.subscriptions.push(breakpointObserver.observe([
            Breakpoints.TabletPortrait,
            Breakpoints.Small
        ]).subscribe((result) => {
            if (result.matches) {
                this.currentSize = 'tablet';
                this.buildGrid();
            }
        }));
        this.subscriptions.push(breakpointObserver.observe([
            Breakpoints.TabletLandscape,
            Breakpoints.WebLandscape,
        ]).subscribe((result) => {
            if (result.matches) {
                this.currentSize = 'web';
                this.buildGrid();
            }
        }));
        this.subscriptions.push(breakpointObserver.observe([
            Breakpoints.XLarge,
        ]).subscribe((result) => {
            if (result.matches) {
                this.currentSize = 'wide';
                this.buildGrid();
            }
        }));
    }
    static { this.ɵfac = function BaseFieldGridComponent_Factory(t) { return new (t || BaseFieldGridComponent)(i0.ɵɵdirectiveInject(i1$1.BreakpointObserver)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: BaseFieldGridComponent, inputs: { special: "special", actions: "actions", appendActions: "appendActions", labelDisplay: "labelDisplay", labelClass: "labelClass", inputClass: "inputClass", rowClass: "rowClass", colClass: "colClass", colAlignItems: "colAlignItems", maxColumns: "maxColumns", sizeMap: "sizeMap" } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFieldGridComponent, [{
        type: Directive
    }], function () { return [{ type: i1$1.BreakpointObserver }]; }, { special: [{
            type: Input
        }], actions: [{
            type: Input
        }], appendActions: [{
            type: Input
        }], labelDisplay: [{
            type: Input
        }], labelClass: [{
            type: Input
        }], inputClass: [{
            type: Input
        }], rowClass: [{
            type: Input
        }], colClass: [{
            type: Input
        }], colAlignItems: [{
            type: Input
        }], maxColumns: [{
            type: Input
        }], sizeMap: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseActionManager {
    constructor() {
        this.actions = {
            edit: {},
            create: {},
            list: {},
            detail: {},
            massupdate: {},
            filter: {}
        };
    }
    run(action, mode, data) {
        if (!this.actions || !this.actions[mode] || !this.actions[mode][action.key]) {
            return;
        }
        this.actions[mode][action.key].run(data, action);
    }
    getHandler(action, mode) {
        let handlerKey = action.key;
        if (action && action.asyncProcess) {
            handlerKey = 'async-process';
        }
        if (!this.actions || !this.actions[mode] || !this.actions[mode][handlerKey]) {
            return null;
        }
        return this.actions[mode][handlerKey];
    }
    addHandler(action, mode, handler) {
        if (!this.actions[mode]) {
            this.actions[mode] = {};
        }
        this.actions[mode][action.key] = handler;
    }
    static { this.ɵfac = function BaseActionManager_Factory(t) { return new (t || BaseActionManager)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseActionManager, factory: BaseActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldLogicActionHandler extends ActionHandler {
    shouldDisplay(data) {
        return true;
    }
    ;
    getTriggeringStatus() {
        return ['onValueChange'];
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ConditionOperatorActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GreaterThanAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'greater-than';
    }
    run(record, field, opsConfig) {
        const comparisonValue = opsConfig.field ? record.fields[opsConfig.field].value : opsConfig.value;
        return Number(field.value) > Number(comparisonValue);
    }
    static { this.ɵfac = function GreaterThanAction_Factory(t) { return new (t || GreaterThanAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GreaterThanAction, factory: GreaterThanAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GreaterThanAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LessThanAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'less-than';
    }
    run(record, field, opsConfig) {
        const comparisonValue = opsConfig.field ? record.fields[opsConfig.field].value : opsConfig.value;
        return Number(field.value) < Number(comparisonValue);
    }
    static { this.ɵfac = function LessThanAction_Factory(t) { return new (t || LessThanAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LessThanAction, factory: LessThanAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LessThanAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NotEmptyAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'not-empty';
    }
    run(record, field, opsConfig) {
        if (!isEmptyString(field.value)) {
            return true;
        }
        return false;
    }
    static { this.ɵfac = function NotEmptyAction_Factory(t) { return new (t || NotEmptyAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NotEmptyAction, factory: NotEmptyAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotEmptyAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IsEmptyAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'is-empty';
    }
    run(record, field, opsConfig) {
        if (isEmptyString(field.value)) {
            return true;
        }
        return false;
    }
    static { this.ɵfac = function IsEmptyAction_Factory(t) { return new (t || IsEmptyAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IsEmptyAction, factory: IsEmptyAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IsEmptyAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IsEqualAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'is-equal';
    }
    run(record, field, opsConfig) {
        let comparisonValue = null;
        if (this.compareToField(opsConfig)) {
            comparisonValue = this.getFieldComparisonValue(record, opsConfig);
        }
        else {
            comparisonValue = this.getStaticComparisonValue(opsConfig);
        }
        if (comparisonValue) {
            return comparisonValue.includes(field.value.toString());
        }
        return false;
    }
    getFieldComparisonValue(record, opsConfig) {
        return [record.fields[opsConfig.field]?.value];
    }
    getStaticComparisonValue(opsConfig) {
        if (Array.isArray(opsConfig.values)) {
            return opsConfig.values.map(value => value?.toString());
        }
        return [opsConfig.value].map(value => value?.toString());
    }
    compareToField(opsConfig) {
        if (opsConfig?.field) {
            return true;
        }
        return false;
    }
    static { this.ɵfac = function IsEqualAction_Factory(t) { return new (t || IsEqualAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IsEqualAction, factory: IsEqualAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IsEqualAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NotEqualAction extends ConditionOperatorActionHandler {
    constructor() {
        super();
        this.key = 'not-equal';
    }
    run(record, field, opsConfig) {
        const comparisonValue = opsConfig.field ? [record.fields[opsConfig.field].value] : (Array.isArray(opsConfig.values) ? opsConfig.values : [opsConfig.value]).map(value => value.toString());
        if (comparisonValue) {
            return !comparisonValue.includes(field.value.toString());
        }
        return false;
    }
    static { this.ɵfac = function NotEqualAction_Factory(t) { return new (t || NotEqualAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NotEqualAction, factory: NotEqualAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotEqualAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ConditionOperatorManager {
    constructor(greaterThanAction, lessThanAction, notEmptyAction, isEmptyAction, isEqualAction, notEqualAction) {
        this.greaterThanAction = greaterThanAction;
        this.lessThanAction = lessThanAction;
        this.notEmptyAction = notEmptyAction;
        this.isEmptyAction = isEmptyAction;
        this.isEqualAction = isEqualAction;
        this.notEqualAction = notEqualAction;
    }
    get(key) {
        const operatorMap = {
            'greater-than': this.greaterThanAction,
            'less-than': this.lessThanAction,
            'not-empty': this.notEmptyAction,
            'is-empty': this.isEmptyAction,
            'is-equal': this.isEqualAction,
            'not-equal': this.notEqualAction,
        };
        return operatorMap[key];
    }
    static { this.ɵfac = function ConditionOperatorManager_Factory(t) { return new (t || ConditionOperatorManager)(i0.ɵɵinject(GreaterThanAction), i0.ɵɵinject(LessThanAction), i0.ɵɵinject(NotEmptyAction), i0.ɵɵinject(IsEmptyAction), i0.ɵɵinject(IsEqualAction), i0.ɵɵinject(NotEqualAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ConditionOperatorManager, factory: ConditionOperatorManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConditionOperatorManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: GreaterThanAction }, { type: LessThanAction }, { type: NotEmptyAction }, { type: IsEmptyAction }, { type: IsEqualAction }, { type: NotEqualAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
/**
 * @DEPRECATED
 */
class FieldLogicDisplayTypeAction extends FieldLogicActionHandler {
    constructor(operatorManager) {
        super();
        this.operatorManager = operatorManager;
        this.key = 'displayType';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return;
        }
        const targetDisplay = action.params && action.params.targetDisplayType;
        if (!targetDisplay) {
            return;
        }
        let isActive = this.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        let display = data.field.defaultDisplay;
        if (isActive) {
            display = targetDisplay;
        }
        data.field.display = display;
        const resetOn = (action.params && action.params.resetOn) || 'none';
        if (resetOn === display) {
            if (data.field.valueList && data.field.valueList.length) {
                data.field.valueList = [];
            }
            if (data.field.value) {
                data.field.value = '';
            }
        }
    }
    /**
     * Check if any of the configured values is currently set
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     * @param {array} relatedAttributesFields
     * @param {object} activeOnAttributes
     */
    isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes) {
        let isActive = false;
        if (!isActive && !isEmpty(activeOnFields)) {
            isActive = this.areFieldsActive(relatedFields, record, activeOnFields);
        }
        if (!isActive && !isEmpty(activeOnAttributes)) {
            isActive = this.areAttributesActive(relatedAttributesFields, record, activeOnAttributes);
        }
        return isActive;
    }
    /**
     * Are attributes active
     * @param {array} relatedAttributesFields
     * @param {object} record
     * @param {object} activeOnAttributes
     */
    areAttributesActive(relatedAttributesFields, record, activeOnAttributes) {
        return relatedAttributesFields.some(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const attributes = activeOnAttributes[fieldKey] && Object.keys(activeOnAttributes[fieldKey]);
            if (!field || !attributes || !attributes.length) {
                return;
            }
            return attributes.some(attributeKey => {
                const activeValues = activeOnAttributes[fieldKey][attributeKey];
                const attribute = field.attributes && field.attributes[attributeKey];
                if (!activeValues || !activeValues.length || !attribute) {
                    return;
                }
                return this.isValueActive(record, attribute, activeValues);
            });
        });
    }
    /**
     * Are fields active
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     */
    areFieldsActive(relatedFields, record, activeOnFields) {
        return relatedFields.every(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const activeValues = activeOnFields[fieldKey];
            if (!field || !activeValues || !activeValues.length) {
                return;
            }
            return this.isValueActive(record, field, activeValues);
        });
    }
    /**
     * Is value active
     * @param record
     * @param {object} field
     * @param {array} activeValues
     */
    isValueActive(record, field, activeValues) {
        let isActive = false;
        if (field.valueList && field.valueList.length) {
            field.valueList.some(value => {
                return activeValues.some(activeValue => {
                    if (activeValue === value) {
                        isActive = true;
                        return true;
                    }
                });
            });
            return isActive;
        }
        const fields = Object.keys(record.fields);
        let opsArr = [];
        if (field.value) {
            activeValues.some(activeValue => {
                if (activeValue.field && !fields.includes(activeValue.field)) {
                    return;
                }
                if (activeValue === field.value && !activeValue.operator) {
                    isActive = true;
                }
                if (activeValue.operator) {
                    const operatorKey = activeValue.operator;
                    const operator = this.operatorManager.get(operatorKey);
                    opsArr.push(operator.run(record, field, activeValue));
                    isActive = opsArr.every(data => data);
                }
            });
        }
        else {
            activeValues.some(activeValue => {
                if (activeValue.operator) {
                    if (activeValue.field && !fields.includes(activeValue.field)) {
                        return;
                    }
                    const operatorKey = activeValue.operator;
                    const operator = this.operatorManager.get(operatorKey);
                    opsArr.push(operator.run(record, field, activeValue));
                    isActive = opsArr.every(data => data);
                }
            });
        }
        return isActive;
    }
    getTriggeringStatus() {
        return ['onValueChange', 'onFieldInitialize'];
    }
    static { this.ɵfac = function FieldLogicDisplayTypeAction_Factory(t) { return new (t || FieldLogicDisplayTypeAction)(i0.ɵɵinject(ConditionOperatorManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldLogicDisplayTypeAction, factory: FieldLogicDisplayTypeAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLogicDisplayTypeAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ConditionOperatorManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EmailPrimarySelectAction extends FieldLogicActionHandler {
    constructor() {
        super();
        this.key = 'emailPrimarySelect';
        this.modes = ['edit', 'create', 'massupdate'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const items = field.items;
        if (!field || !items || !items.length) {
            return;
        }
        const activeItems = items.filter(item => !(item && item.attributes && item.attributes.deleted));
        // Auto-select the primary, only when the number of displayed rows equal to one;
        // This logic applies either via Add or Remove
        if (activeItems && activeItems.length !== 1) {
            return;
        }
        const item = activeItems[0];
        const emailField = (item.fields && item.fields['email-fields']) || {};
        const primary = (emailField.attributes && emailField.attributes['primary_address']) || null;
        if (primary && !isTrue(primary.value)) {
            primary.value = 'true';
            primary.formControl.setValue('true');
            // re-validate the parent form-control after value update
            emailField.formControl.updateValueAndValidity({ onlySelf: true, emitEvent: true });
        }
    }
    static { this.ɵfac = function EmailPrimarySelectAction_Factory(t) { return new (t || EmailPrimarySelectAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: EmailPrimarySelectAction, factory: EmailPrimarySelectAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailPrimarySelectAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const requiredValidator = (utils) => ((control) => {
    if (utils.isEmptyTrimmedInputValue(control.value)) {
        return {
            required: {
                required: true,
                message: {
                    labelKey: 'LBL_VALIDATION_ERROR_REQUIRED',
                    context: {
                        value: control.value
                    }
                }
            }
        };
    }
    return null;
});
const booleanRequiredValidator = (utils) => ((control) => {
    if (utils.isEmptyBooleanInputValue(control.value)) {
        return {
            required: {
                required: true,
                message: {
                    labelKey: 'LBL_VALIDATION_ERROR_REQUIRED',
                    context: {
                        value: control.value
                    }
                }
            }
        };
    }
    return null;
});
const multienumRequiredValidator = (viewField, record, utils) => ((control) => {
    const name = viewField.name || '';
    if (!name || !record || !record.fields) {
        return null;
    }
    const field = record?.fields[name] ?? {};
    if (!field) {
        return null;
    }
    const activeItems = field.valueList;
    if (activeItems && activeItems.length > 0) {
        return null;
    }
    return {
        required: {
            required: true,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_REQUIRED',
                context: {}
            }
        }
    };
});
class RequiredValidator {
    constructor(utils) {
        this.utils = utils;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        const viewFieldType = viewField?.type ?? null;
        const fieldDefinitionType = viewField?.fieldDefinition?.type ?? null;
        if (viewFieldType === 'line-items' || fieldDefinitionType === 'line-items') {
            return false;
        }
        return isTrue(viewField.fieldDefinition.required);
    }
    getValidator(viewField, record) {
        const type = viewField?.type ?? viewField?.fieldDefinition?.type ?? '';
        if (type === 'boolean') {
            return [booleanRequiredValidator(this.utils)];
        }
        if (type === 'multienum') {
            return [multienumRequiredValidator(viewField, record, this.utils)];
        }
        return [requiredValidator(this.utils)];
    }
    static { this.ɵfac = function RequiredValidator_Factory(t) { return new (t || RequiredValidator)(i0.ɵɵinject(FormControlUtils)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RequiredValidator, factory: RequiredValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RequiredValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FormControlUtils }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ActiveFieldsChecker {
    constructor(operatorManager) {
        this.operatorManager = operatorManager;
    }
    /**
     * Check if any of the configured values is currently set
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     * @param {array} relatedAttributesFields
     * @param {object} activeOnAttributes
     */
    isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes) {
        let isActive = true;
        if (!isEmpty(activeOnFields)) {
            isActive = this.areFieldsActive(relatedFields, record, activeOnFields);
        }
        if (!isEmpty(activeOnAttributes)) {
            isActive = isActive && this.areAttributesActive(relatedAttributesFields, record, activeOnAttributes);
        }
        return isActive;
    }
    /**
     * Are attributes active
     * @param {array} relatedAttributesFields
     * @param {object} record
     * @param {object} activeOnAttributes
     */
    areAttributesActive(relatedAttributesFields, record, activeOnAttributes) {
        return relatedAttributesFields.every(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const attributes = activeOnAttributes[fieldKey] && Object.keys(activeOnAttributes[fieldKey]);
            if (!field || !attributes || !attributes.length) {
                return;
            }
            return attributes.some(attributeKey => {
                const activeValues = activeOnAttributes[fieldKey][attributeKey];
                const attribute = field.attributes && field.attributes[attributeKey];
                if (!activeValues || !activeValues.length || !attribute) {
                    return;
                }
                return this.isValueActive(record, attribute, activeValues);
            });
        });
    }
    /**
     * Are fields active
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     */
    areFieldsActive(relatedFields, record, activeOnFields) {
        return relatedFields.every(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const activeValues = activeOnFields[fieldKey];
            if (!field || !activeValues || !activeValues.length) {
                return true;
            }
            return this.isValueActive(record, field, activeValues);
        });
    }
    /**
     * Is value active
     * @param {object} record
     * @param {object} field
     * @param {array} activeValues
     */
    isValueActive(record, field, activeValues) {
        let isActive = false;
        if (field.valueList && field.valueList.length) {
            field.valueList.some(value => {
                return activeValues.some(activeValue => {
                    if (activeValue === value) {
                        isActive = true;
                        return true;
                    }
                });
            });
            return isActive;
        }
        const fields = Object.keys(record.fields);
        let opsArr = [];
        activeValues.some(activeValue => {
            if (activeValue.field && !fields.includes(activeValue.field)) {
                return;
            }
            if (isTrue(activeValue) || isFalse(activeValue)) {
                isActive = activeValue.toString() === field.value.toString();
                return;
            }
            const operatorKey = activeValue?.operator ?? 'is-equal';
            if (typeof activeValue === 'string') {
                activeValue = {
                    operator: operatorKey,
                    values: [activeValue]
                };
            }
            const operator = this.operatorManager.get(operatorKey);
            opsArr.push(operator.run(record, field, activeValue));
            isActive = opsArr.every(data => data);
        });
        return isActive;
    }
    static { this.ɵfac = function ActiveFieldsChecker_Factory(t) { return new (t || ActiveFieldsChecker)(i0.ɵɵinject(ConditionOperatorManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActiveFieldsChecker, factory: ActiveFieldsChecker.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActiveFieldsChecker, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ConditionOperatorManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RequiredAction extends FieldLogicActionHandler {
    constructor(requiredValidator, activeFieldsChecker) {
        super();
        this.requiredValidator = requiredValidator;
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'required';
        this.modes = ['edit', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return;
        }
        const isActive = this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        let required = false;
        let validators = [...data.field.validators || []];
        if (isActive) {
            required = true;
            validators = validators.concat(this.requiredValidator.getValidator(field, record));
        }
        data.field.formControl.updateValueAndValidity({ onlySelf: true, emitEvent: true });
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
        data.field.definition.required = required;
        data.field.formControl.setValidators(validators);
        data.field.formControl.updateValueAndValidity({ onlySelf: true, emitEvent: true });
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    getTriggeringStatus() {
        return ['onValueChange', 'onFieldInitialize'];
    }
    static { this.ɵfac = function RequiredAction_Factory(t) { return new (t || RequiredAction)(i0.ɵɵinject(RequiredValidator), i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RequiredAction, factory: RequiredAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RequiredAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: RequiredValidator }, { type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CurrencyService {
    constructor(config, preferences) {
        this.config = config;
        this.preferences = preferences;
    }
    getFieldCurrencyValue(field, record) {
        const isBase = this.isBase(field);
        const currencyId = this.getCurrencyId(record);
        if (!isBase && currencyId !== null) {
            return field.value;
        }
        const value = parseFloat(field.value);
        if (!isFinite(value)) {
            return field.value;
        }
        const userCurrency = this.getUserCurrency();
        return this.baseToCurrency(userCurrency.id, value).toString();
    }
    baseToCurrency(currencyId, value) {
        const conversionRate = this.getConversionRate(currencyId);
        if (!isFinite(conversionRate)) {
            return value;
        }
        return this.round(multiply(value, conversionRate));
    }
    currencyToBase(currencyId, value) {
        const conversionRate = this.getConversionRate(currencyId);
        if (!isFinite(conversionRate)) {
            return value;
        }
        return this.round(divide(value, conversionRate));
    }
    round(value) {
        const precision = this.getPrecision();
        return round(value, precision);
    }
    getCurrencyId(record) {
        return record?.fields?.currency_id?.value ?? null;
    }
    isBase(field) {
        return field?.metadata?.isBaseCurrency ?? false;
    }
    getCurrency(id) {
        const currencies = this.config.getConfigValue('currencies');
        return currencies[id] ?? [];
    }
    getBaseCurrency() {
        return this.config.getConfigValue('currency');
    }
    getUserCurrency() {
        return this.preferences.getUserPreference('currency');
    }
    getPrecision() {
        const userPrecision = parseInt(this.preferences.getUserPreference('default_currency_significant_digits'));
        if (isFinite(userPrecision)) {
            return userPrecision;
        }
        const systemPrecision = parseInt(this.config.getConfigValue('default_currency_significant_digits'));
        if (isFinite(systemPrecision)) {
            return systemPrecision;
        }
        return 0;
    }
    getConversionRate(id) {
        const currency = this.getCurrency(id);
        return parseFloat(currency['conversion_rate']);
    }
    getCode(id) {
        return this.getCurrency(id).iso4217;
    }
    getSymbol(id) {
        return this.getCurrency(id).symbol;
    }
    static { this.ɵfac = function CurrencyService_Factory(t) { return new (t || CurrencyService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CurrencyService, factory: CurrencyService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SystemConfigStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UpdateBaseCurrencyAction extends FieldLogicActionHandler {
    constructor(currencyService) {
        super();
        this.currencyService = currencyService;
        this.key = 'update-base-currency';
        this.modes = ['edit', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const currencyIdFieldName = action.params.currencyIdField ?? 'currency_id';
        const currencyFieldName = action.params.currencyField ?? 'amount';
        const currencyId = record?.fields[currencyIdFieldName]?.value ?? null;
        let value = parseFloat(record?.fields[currencyFieldName]?.value ?? null);
        if (!isFinite(value)) {
            return;
        }
        if (currencyId === null) {
            this.updateValue(field, value, record);
        }
        const baseValue = this.currencyService.currencyToBase(currencyId, value);
        if (!isFinite(baseValue)) {
            return;
        }
        this.updateValue(field, baseValue, record);
    }
    updateValue(field, baseValue, record) {
        field.value = baseValue.toString();
        field.formControl.setValue(baseValue.toString());
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function UpdateBaseCurrencyAction_Factory(t) { return new (t || UpdateBaseCurrencyAction)(i0.ɵɵinject(CurrencyService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UpdateBaseCurrencyAction, factory: UpdateBaseCurrencyAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UpdateBaseCurrencyAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: CurrencyService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UpdateCurrencyAction extends FieldLogicActionHandler {
    constructor(currencyService) {
        super();
        this.currencyService = currencyService;
        this.key = 'update-currency';
        this.modes = ['edit', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        const isBaseCurrency = field?.definition?.metadata?.isBaseCurrency ?? false;
        if (!record || !field || isBaseCurrency) {
            return;
        }
        const currencyIdFieldName = action.params.currencyIdField ?? 'currency_id';
        const baseCurrencyFieldName = action.params.baseCurrencyField ?? 'amount_usdollar';
        const currencyId = record?.fields[currencyIdFieldName]?.value ?? null;
        let value = parseFloat(field?.value ?? null);
        let baseValue = parseFloat(record?.fields[baseCurrencyFieldName]?.value ?? null);
        if (!isFinite(value) || !isFinite(baseValue) || currencyId === null) {
            return;
        }
        const newValue = this.currencyService.baseToCurrency(currencyId, baseValue);
        if (!isFinite(newValue)) {
            return;
        }
        this.updateValue(field, newValue, record);
    }
    updateValue(field, value, record) {
        field.value = value.toString();
        field.formControl.setValue(value.toString());
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function UpdateCurrencyAction_Factory(t) { return new (t || UpdateCurrencyAction)(i0.ɵɵinject(CurrencyService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UpdateCurrencyAction, factory: UpdateCurrencyAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UpdateCurrencyAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: CurrencyService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UpdateFlexRelateModuleAction extends FieldLogicActionHandler {
    constructor() {
        super();
        this.key = 'update-flex-relate-module';
        this.modes = ['edit', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const typeField = field.definition.type_name ?? '';
        if (typeField === '') {
            return;
        }
        const type = record?.fields[typeField]?.value ?? '';
        const fieldModule = field?.definition?.module ?? '';
        if (type !== fieldModule) {
            field.definition.module = record?.fields[typeField]?.value ?? '';
            this.updateValue(field, {}, '', record);
        }
    }
    updateValue(field, valueObject, value, record) {
        field.value = value;
        field.valueObject = valueObject;
        field.formControl.setValue(value);
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function UpdateFlexRelateModuleAction_Factory(t) { return new (t || UpdateFlexRelateModuleAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UpdateFlexRelateModuleAction, factory: UpdateFlexRelateModuleAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UpdateFlexRelateModuleAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UpdateValueAction extends FieldLogicActionHandler {
    constructor(activeFieldsChecker) {
        super();
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'updateValue';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return;
        }
        const targetValue = action.params && action.params.targetValue;
        if (!targetValue) {
            return;
        }
        const isActive = this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        let value = data.field?.value;
        if (isActive) {
            value = targetValue;
        }
        this.updateValue(field, value.toString(), record);
    }
    /**
     * Update the new value
     * @param {object} field
     * @param {object} record
     */
    updateValue(field, value, record) {
        field.value = value.toString();
        field.formControl.setValue(value);
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function UpdateValueAction_Factory(t) { return new (t || UpdateValueAction)(i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UpdateValueAction, factory: UpdateValueAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UpdateValueAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021-2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MessageService {
    constructor(config) {
        this.config = config;
        this.messages = [];
        this.timeout = 3;
        this.messagesStage = new BehaviorSubject([]);
        this.messages$ = this.messagesStage.asObservable();
        this.initTimeOut();
    }
    updateState(messages) {
        this.messagesStage.next(this.messages = messages);
    }
    removeMessages() {
        this.updateState([]);
    }
    contains(message, remove = false) {
        let found = false;
        for (let i = 0; i < this.messages.length; i++) {
            if (!this.isSame(message, this.messages[i])) {
                continue;
            }
            found = true;
            if (remove) {
                const messages = [...this.messages];
                messages.splice(i, 1);
                this.updateState(messages);
            }
            break;
        }
        return found;
    }
    addMessage(message) {
        // push message only if it does not contains already...
        let ret = -1;
        if (!this.contains(message)) {
            const newMessages = [...this.messages];
            ret = newMessages.push(message);
            if (message.type === MessageTypes.success || message.type === MessageTypes.warning) {
                setTimeout(() => {
                    this.contains(message, true);
                }, this.timeout * 1000);
            }
            this.updateState(newMessages);
        }
        return ret;
    }
    addPrimaryMessage(text) {
        return this.addMessage({
            type: MessageTypes.primary,
            text
        });
    }
    addSecondaryMessage(text) {
        return this.addMessage({
            type: MessageTypes.secondary,
            text
        });
    }
    addSuccessMessage(text) {
        return this.addMessage({
            type: MessageTypes.success,
            text
        });
    }
    addSuccessMessageByKey(labelKey) {
        return this.addMessage({
            type: MessageTypes.success,
            labelKey
        });
    }
    addDangerMessage(text) {
        return this.addMessage({
            type: MessageTypes.danger,
            text
        });
    }
    addDangerMessageByKey(labelKey) {
        return this.addMessage({
            type: MessageTypes.danger,
            labelKey
        });
    }
    addWarningMessage(text) {
        return this.addMessage({
            type: MessageTypes.warning,
            text
        });
    }
    addWarningMessageByKey(labelKey) {
        return this.addMessage({
            type: MessageTypes.warning,
            labelKey
        });
    }
    addInfoMessage(text) {
        return this.addMessage({
            type: MessageTypes.info,
            text
        });
    }
    addDarkMessage(text) {
        return this.addMessage({
            type: MessageTypes.dark,
            text
        });
    }
    // --- LOG ---
    log(...args) {
        console.log.apply(console, args);
    }
    error(...args) {
        console.error.apply(console, args);
    }
    initTimeOut() {
        const ui = this.config.getConfigValue('ui');
        if (ui && ui.alert_timeout) {
            const parsed = parseInt(ui.alert_timeout, 10);
            if (!isNaN(parsed)) {
                this.timeout = parsed;
            }
        }
    }
    /**
     * Compare the text/labelKey on two messages. LabelKey always takes priority
     *
     * @param {Message} newMessage New Message
     * @param {Message} existingMessage Existing Message
     * @protected
     * @returns {boolean} True if is the same
     */
    isSame(newMessage, existingMessage) {
        let sourceField = 'text';
        if (newMessage.labelKey) {
            sourceField = 'labelKey';
        }
        return newMessage[sourceField] === existingMessage[sourceField];
    }
    static { this.ɵfac = function MessageService_Factory(t) { return new (t || MessageService)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MessageService, factory: MessageService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RedirectAsyncAction extends AsyncActionHandler {
    constructor(router, message) {
        super();
        this.router = router;
        this.message = message;
        this.key = 'redirect';
    }
    run(data) {
        if (!data || !data.route) {
            this.message.addDangerMessageByKey('LBL_MISSING_HANDLER_DATA_ROUTE');
            return;
        }
        const params = {
            queryParams: {}
        };
        if (data.queryParams) {
            params.queryParams = data.queryParams;
        }
        this.router.navigate([data.route], params).then();
    }
    static { this.ɵfac = function RedirectAsyncAction_Factory(t) { return new (t || RedirectAsyncAction)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RedirectAsyncAction, factory: RedirectAsyncAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RedirectAsyncAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$2.Router }, { type: MessageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ExportAsyncAction extends AsyncActionHandler {
    constructor(message) {
        super();
        this.message = message;
        this.key = 'export';
    }
    run(data) {
        if (!data || !data.url || !data.formData) {
            this.message.addDangerMessageByKey('LBL_MISSING_HANDLER_DATA_ROUTE');
            return;
        }
        const options = {
            responseType: 'blob',
            observe: 'response',
        };
        if (data.queryParams) {
            options.params = data.queryParams;
        }
        this.download(data.url, data.formData);
    }
    /**
     * Download file
     *
     * NOTE: using a hidden form instead of js for better memory management see:
     * https://github.com/eligrey/FileSaver.js/wiki/Saving-a-remote-file#using-a-form-element-other-than-get-methods
     *
     * @param {string} url for download
     * @param {object} formData to submit
     */
    download(url, formData) {
        const form = document.createElement('form');
        form.setAttribute('id', 'export-download');
        form.setAttribute('method', 'post');
        form.setAttribute('action', url);
        form.setAttribute('target', '_self');
        form.setAttribute('style', 'display: none;');
        Object.keys(formData).forEach(key => {
            const hiddenField = document.createElement('input');
            hiddenField.setAttribute('name', key);
            hiddenField.setAttribute('value', formData[key]);
            form.appendChild(hiddenField);
        });
        document.body.appendChild(form);
        form.submit();
        document.body.removeChild(form);
    }
    static { this.ɵfac = function ExportAsyncAction_Factory(t) { return new (t || ExportAsyncAction)(i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ExportAsyncAction, factory: ExportAsyncAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ExportAsyncAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NoopAsyncAction extends AsyncActionHandler {
    constructor() {
        super();
        this.key = 'noop';
    }
    run(data) {
    }
    static { this.ɵfac = function NoopAsyncAction_Factory(t) { return new (t || NoopAsyncAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NoopAsyncAction, factory: NoopAsyncAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NoopAsyncAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IframeResizeHandlerHandler {
    constructor() {
    }
    /**
     * Public Api
     */
    init(iframe) {
        this.iframe = iframe;
        this.initialSizeAdjustment();
        this.addBodyResizeListener();
    }
    destroy() {
        if (this.observer) {
            this.observer.disconnect();
        }
        this.iframe = null;
        this.observer = null;
    }
    /**
     * Protected Api
     */
    initialSizeAdjustment() {
        setTimeout(this.onResize.bind(this), 200);
    }
    addBodyResizeListener() {
        const watchedData = {
            document: this.iframe.contentWindow.document,
            element: this.iframe.contentWindow.document.body,
            height: this.iframe.contentWindow.document.body.scrollHeight,
            watched: [
                {
                    getHeight: () => {
                        const modals = watchedData.document.getElementsByClassName('modal in');
                        const modal = modals && modals[0];
                        const modalDialog = modal && modal.firstElementChild;
                        return (modalDialog && (modalDialog.scrollHeight + 200)) || -1;
                    }
                },
                {
                    getHeight: () => {
                        const container = watchedData.document.getElementById('bootstrap-container');
                        const containerHeight = (container && container.scrollHeight + 150) || -1;
                        if (containerHeight > 0) {
                            return containerHeight;
                        }
                        return watchedData.element.scrollHeight + 50;
                    }
                }
            ]
        };
        this.observer = (new MutationObserverFactory()).create(() => {
            const heights = [];
            watchedData.watched.forEach((watched) => {
                const elHeight = watched.getHeight();
                if (elHeight > 0) {
                    heights.push(elHeight);
                }
            });
            heights.sort((a, b) => a - b);
            // consider the Height of the biggest
            const elementHeight = heights.pop();
            const feedback = this.calculateResizing(watchedData.height, elementHeight);
            if (feedback.resized) {
                watchedData.height = feedback.height;
            }
        });
        this.observer.observe(this.iframe.contentWindow.document.body, {
            attributes: true,
            childList: true,
            characterData: true,
            subtree: true
        });
    }
    calculateResizing(currentHeight, elementHeight) {
        const availableWindowHeight = window.innerHeight - 50;
        // if window size is bigger, take that size
        if (elementHeight < availableWindowHeight) {
            elementHeight = availableWindowHeight;
        }
        if (currentHeight === elementHeight) {
            return {
                resized: false
            };
        }
        if (currentHeight < (elementHeight - 20)) {
            this.resizeIFrame(elementHeight);
            return {
                resized: true,
                height: elementHeight
            };
        }
        if (this.iframe.scrollHeight > elementHeight) {
            this.resizeIFrame(elementHeight);
            return {
                resized: true,
                height: elementHeight
            };
        }
        return {
            resized: false
        };
    }
    onResize() {
        const elementHeight = this.iframe.contentWindow.document.body.scrollHeight + 120;
        const currentHeight = this.iframe.offsetHeight;
        this.calculateResizing(currentHeight, elementHeight);
    }
    resizeIFrame(size) {
        const adjustedValue = size + 1;
        this.iframe.style.height = adjustedValue + 'px';
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IframePageChangeObserver {
    constructor(iframe, changeCallback = null, loadCallback = null, unLoadCallback = null) {
        this.changeCallback = null;
        this.loadCallback = null;
        this.unLoadCallback = null;
        this.unloadListener = null;
        this.loadListener = null;
        this.iframe = iframe;
        this.changeCallback = changeCallback;
        this.loadCallback = loadCallback;
        this.unLoadCallback = unLoadCallback;
    }
    /**
     * Public Api
     */
    init() {
        this.loadListener = this.loadHandler.bind(this);
        this.unloadListener = this.unloadHandler.bind(this);
        this.iframe.contentWindow.addEventListener('load', this.loadListener);
        this.iframe.contentWindow.removeEventListener('unload', this.unloadListener);
    }
    destroy() {
        const contentWindow = this.iframe && this.iframe.contentWindow;
        if (contentWindow) {
            contentWindow.removeEventListener('unload', this.unloadListener);
            contentWindow.removeEventListener('load', this.loadListener);
        }
        this.iframe = null;
        this.lastDispatched = null;
        this.changeCallback = null;
        this.loadCallback = null;
        this.unLoadCallback = null;
        this.loadListener = null;
        this.unloadListener = null;
    }
    /**
     * Internal API
     */
    loadHandler() {
        this.loadCallback();
        this.bindUnload();
    }
    bindUnload() {
        this.iframe.contentWindow.removeEventListener('unload', this.unloadListener);
        this.unloadListener = this.unloadHandler.bind(this);
        this.iframe.contentWindow.addEventListener('unload', this.unloadListener);
    }
    unloadHandler() {
        this.unLoadCallback();
        // Timeout needed because the URL changes immediately after
        // the `unload` event is dispatched.
        setTimeout(this.triggerPageChange.bind(this), 0);
    }
    triggerPageChange() {
        const newHref = this.iframe && this.iframe.contentWindow && this.iframe.contentWindow.location.href;
        if (newHref && newHref !== this.lastDispatched) {
            this.lastDispatched = newHref;
            this.changeCallback(newHref);
        }
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$H = ["dataContainer"];
class ClassicModalComponent {
    constructor(languageStore, activeModal) {
        this.languageStore = languageStore;
        this.activeModal = activeModal;
        this.url = '';
        this.titleKey = '';
        this.asyncActionCallback = null;
        this.iframe = null;
    }
    ngOnInit() {
        this.closeButton = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.activeModal.close({
                    type: 'close-button'
                });
            }
        };
    }
    ngAfterViewInit() {
        this.initIframe();
    }
    ngOnDestroy() {
        this.cleanObservers();
        this.iframe = null;
        const placeholder = this.wrapper;
        if (this.wrapper.firstChild) {
            placeholder.removeChild(placeholder.firstChild);
        }
        placeholder.innerHTML = '<iframe></iframe>';
        this.wrapper = null;
    }
    cleanObservers() {
        if (this.iframeResizeHandler) {
            this.iframeResizeHandler.destroy();
            this.iframeResizeHandler = null;
        }
        if (this.iframePageChangeHandler) {
            this.iframePageChangeHandler.destroy();
            this.iframePageChangeHandler = null;
        }
    }
    initIframe() {
        this.wrapper = this.dataContainer.nativeElement;
        if (this.wrapper.firstChild) {
            this.wrapper.removeChild(this.wrapper.firstChild);
        }
        const iframe = document.createElement('iframe');
        iframe.src = this.url;
        this.wrapper.appendChild(iframe);
        this.iframe = iframe;
        this.iframe.style.display = 'block';
        this.initObservers();
    }
    initObservers() {
        this.iframePageChangeHandler = this.buildIframePageChangeObserver();
        this.iframeResizeHandler = this.buildIframeResizeHandlerHandler();
        if (this.iframePageChangeHandler) {
            this.iframePageChangeHandler.init();
        }
    }
    onIFrameLoad() {
        // Do not show scroll at any time, to avoid flickering
        this.iframe.contentWindow.document.body.style.overflow = 'hidden';
        // callback function to execute custom task
        // as required by the caller
        if (this.asyncActionCallback !== null) {
            this.asyncActionCallback(this.iframe);
        }
        // Init resize handler
        this.iframeResizeHandler.init(this.iframe);
    }
    onIFrameUnload() {
        // hide iframe, while being re-directed
        this.iframe.style.display = 'none';
        this.iframeResizeHandler.destroy();
    }
    buildIframePageChangeObserver() {
        return new IframePageChangeObserver(this.iframe, null, this.onIFrameLoad.bind(this), this.onIFrameUnload.bind(this));
    }
    buildIframeResizeHandlerHandler() {
        return new IframeResizeHandlerHandler();
    }
    static { this.ɵfac = function ClassicModalComponent_Factory(t) { return new (t || ClassicModalComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(i3$1.NgbActiveModal)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ClassicModalComponent, selectors: [["scrm-classic-modal"]], viewQuery: function ClassicModalComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$H, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dataContainer = _t.first);
        } }, inputs: { url: "url", titleKey: "titleKey", asyncActionCallback: "asyncActionCallback" }, decls: 5, vars: 3, consts: [["bodyKlass", "m-0 small-font", "footerKlass", "border-0", "klass", "classic-view-modal", 3, "closable", "close", "titleKey"], ["modal-body", ""], [1, "classic-view-container"], ["dataContainer", ""]], template: function ClassicModalComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-modal", 0)(1, "div", 1)(2, "div", 2, 3);
            i0.ɵɵelement(4, "iframe");
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵproperty("closable", true)("close", ctx.closeButton)("titleKey", ctx.titleKey);
        } }, dependencies: [ModalComponent], encapsulation: 2, data: { animation: [
                trigger('modalFade', [
                    transition('void <=> *', [
                        animate('800ms')
                    ]),
                ]),
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassicModalComponent, [{
        type: Component,
        args: [{ selector: 'scrm-classic-modal', animations: [
                    trigger('modalFade', [
                        transition('void <=> *', [
                            animate('800ms')
                        ]),
                    ]),
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<scrm-modal [closable]=\"true\"\n            [close]=\"closeButton\"\n            [titleKey]=\"titleKey\"\n            bodyKlass=\"m-0 small-font\"\n            footerKlass=\"border-0\"\n            klass=\"classic-view-modal\">\n\n    <div modal-body>\n\n        <div class=\"classic-view-container\" #dataContainer>\n            <iframe></iframe>\n        </div>\n\n    </div>\n\n</scrm-modal>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: i3$1.NgbActiveModal }]; }, { url: [{
            type: Input
        }], titleKey: [{
            type: Input
        }], asyncActionCallback: [{
            type: Input
        }], dataContainer: [{
            type: ViewChild,
            args: ['dataContainer', { static: true }]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChangelogAsyncAction extends AsyncActionHandler {
    constructor(router, modalService, message) {
        super();
        this.router = router;
        this.modalService = modalService;
        this.message = message;
        this.key = 'audit';
    }
    run(data) {
        if (!data || !data.url) {
            this.message.addDangerMessageByKey('LBL_MISSING_HANDLER_DATA_ROUTE');
            return;
        }
        this.showClassicViewModal(data.url);
    }
    /**
     * Remove title text from iframe source document
     */
    changeLogLegacyContentFormatter(iframeElement) {
        if (!iframeElement) {
            return;
        }
        const node = iframeElement.contentDocument.getElementsByClassName('moduleTitle')[0];
        if (!node) {
            return;
        }
        node.innerText = '';
    }
    /**
     * Show record selection modal
     */
    showClassicViewModal(url) {
        const modal = this.modalService.open(ClassicModalComponent, {
            size: 'xl',
            centered: true,
            scrollable: true
        });
        modal.componentInstance.titleKey = 'LBL_CHANGE_LOG';
        modal.componentInstance.url = url;
        modal.componentInstance.asyncActionCallback = this.changeLogLegacyContentFormatter.bind(this);
    }
    static { this.ɵfac = function ChangelogAsyncAction_Factory(t) { return new (t || ChangelogAsyncAction)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ChangelogAsyncAction, factory: ChangelogAsyncAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChangelogAsyncAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$2.Router }, { type: i3$1.NgbModal }, { type: MessageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncActionService {
    constructor(processService, appStateStore, message, redirectAction, exportAction, noopAction, changelogAction) {
        this.processService = processService;
        this.appStateStore = appStateStore;
        this.message = message;
        this.redirectAction = redirectAction;
        this.exportAction = exportAction;
        this.noopAction = noopAction;
        this.changelogAction = changelogAction;
        this.actions = {};
        this.registerHandler(redirectAction);
        this.registerHandler(exportAction);
        this.registerHandler(noopAction);
        this.registerHandler(changelogAction);
    }
    registerHandler(handler) {
        this.actions[handler.key] = handler;
    }
    /**
     * Send action request
     *
     * @param {string} actionName to submit
     * @param {string} data to send
     * @param {string} presetHandlerKey to use
     * @returns {object} Observable<Process>
     */
    run(actionName, data, presetHandlerKey = null) {
        const options = {
            ...data
        };
        this.appStateStore.updateLoading(actionName, true);
        return this.processService
            .submit(actionName, options)
            .pipe(take(1), tap((process) => {
            this.appStateStore.updateLoading(actionName, false);
            let handler = 'addSuccessMessageByKey';
            if (process.status === 'error') {
                handler = 'addDangerMessageByKey';
            }
            if (process.messages) {
                process.messages.forEach(message => {
                    if (!!message) {
                        this.message[handler](message);
                    }
                });
            }
            if (process.status === 'error') {
                return;
            }
            const actionHandlerKey = presetHandlerKey || (process.data && process.data.handler) || null;
            if (!actionHandlerKey) {
                return;
            }
            const actionHandler = this.actions[actionHandlerKey];
            if (!actionHandler) {
                this.message.addDangerMessageByKey('LBL_MISSING_HANDLER');
                return;
            }
            actionHandler.run(process.data.params);
        }), catchError((err) => {
            const errorMessage = err?.message ?? '';
            if (errorMessage === 'Access Denied.') {
                this.appStateStore.updateLoading(actionName, false);
                return of(null);
            }
            this.message.addDangerMessageByKey('LBL_ACTION_ERROR');
            this.appStateStore.updateLoading(actionName, false);
            return of(null);
        }));
    }
    static { this.ɵfac = function AsyncActionService_Factory(t) { return new (t || AsyncActionService)(i0.ɵɵinject(ProcessService), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RedirectAsyncAction), i0.ɵɵinject(ExportAsyncAction), i0.ɵɵinject(NoopAsyncAction), i0.ɵɵinject(ChangelogAsyncAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncActionService, factory: AsyncActionService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncActionService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: ProcessService }, { type: AppStateStore }, { type: MessageService }, { type: RedirectAsyncAction }, { type: ExportAsyncAction }, { type: NoopAsyncAction }, { type: ChangelogAsyncAction }]; }, null); })();

class BaseSaveRecordMapper {
    getKey() {
        return 'base';
    }
    map(record) {
        if (!record.fields || !Object.keys(record.fields).length) {
            return;
        }
        Object.keys(record.fields).forEach(fieldName => {
            const field = record.fields[fieldName];
            const type = field.type || '';
            const source = field.definition.source || '';
            const rname = field.definition.rname || 'name';
            const idName = field.definition.id_name || '';
            if (type === 'relate' && source === 'non-db' && idName === fieldName) {
                record.attributes[fieldName] = field.value;
                return;
            }
            if (type === 'relate' && source === 'non-db' && rname !== '' && field.valueObject) {
                const attribute = record.attributes[fieldName] || {};
                attribute[rname] = field.valueObject[rname];
                attribute.id = field.valueObject.id;
                record.attributes[fieldName] = attribute;
                record.attributes[idName] = field.valueObject.id;
                return;
            }
            if (field.valueObject) {
                record.attributes[fieldName] = field.valueObject;
                return;
            }
            if (field.items) {
                record.attributes[fieldName] = [];
                field.items.forEach(item => {
                    if (!item?.id && item?.attributes?.deleted) {
                        return;
                    }
                    record.attributes[fieldName].push({
                        id: item.id,
                        module: item.module,
                        attributes: deepClone(item.attributes)
                    });
                });
                return;
            }
            if (field.valueObjectArray) {
                record.attributes[fieldName] = field.valueObjectArray;
                return;
            }
            if (field.valueList) {
                record.attributes[fieldName] = field.valueList;
                return;
            }
            if (field.vardefBased && (isNil(field.value) || field.value === '')) {
                if (!isNil(record.attributes[fieldName])) {
                    delete record.attributes[fieldName];
                }
                return;
            }
            record.attributes[fieldName] = field.value;
        });
    }
    static { this.ɵfac = function BaseSaveRecordMapper_Factory(t) { return new (t || BaseSaveRecordMapper)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseSaveRecordMapper, factory: BaseSaveRecordMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseSaveRecordMapper, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UpdateValueBackendAction extends FieldLogicActionHandler {
    constructor(asyncActionService, processService, messages, recordMappers, baseMapper, activeFieldsChecker) {
        super();
        this.asyncActionService = asyncActionService;
        this.processService = processService;
        this.messages = messages;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'updateValueBackend';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
        recordMappers.register('default', baseMapper.getKey(), baseMapper);
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return;
        }
        const process = action.params && action.params.process;
        if (!process) {
            return;
        }
        const isActive = this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        if (isActive) {
            const processType = process;
            const baseRecord = this.getBaseRecord(record);
            const options = {
                action: processType,
                module: record.module ?? '',
                record: baseRecord
            };
            field.loading = true;
            this.processService.submit(processType, options).pipe(take(1)).subscribe((result) => {
                const value = result?.data?.value ?? null;
                field.loading = false;
                if (value === null) {
                    this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
                    return;
                }
                this.updateValue(field, value.toString(), record);
            }, (error) => {
                field.loading = false;
                this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
            });
        }
    }
    getBaseRecord(record) {
        if (!record) {
            return null;
        }
        this.mapRecordFields(record);
        const baseRecord = {
            id: record.id,
            type: record.type,
            module: record.module,
            attributes: record.attributes,
            acls: record.acls
        };
        return deepClone(baseRecord);
    }
    /**
     * Map staging fields
     */
    mapRecordFields(record) {
        const mappers = this.recordMappers.get(record.module);
        Object.keys(mappers).forEach(key => {
            const mapper = mappers[key];
            mapper.map(record);
        });
    }
    /**
     * Update the new value
     * @param {object} field
     * @param {string} value
     * @param {object} record
     */
    updateValue(field, value, record) {
        field.value = value.toString();
        field.formControl.setValue(value);
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function UpdateValueBackendAction_Factory(t) { return new (t || UpdateValueBackendAction)(i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(ProcessService), i0.ɵɵinject(MessageService), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper), i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UpdateValueBackendAction, factory: UpdateValueBackendAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UpdateValueBackendAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: AsyncActionService }, { type: ProcessService }, { type: MessageService }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }, { type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DisplayTypeBackendAction extends FieldLogicActionHandler {
    constructor(asyncActionService, processService, messages, recordMappers, baseMapper, activeFieldsChecker) {
        super();
        this.asyncActionService = asyncActionService;
        this.processService = processService;
        this.messages = messages;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'displayTypeBackend';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
        recordMappers.register('default', baseMapper.getKey(), baseMapper);
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return;
        }
        const process = action.params && action.params.process;
        if (!process) {
            return;
        }
        const isActive = this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        let display = data.field.defaultDisplay;
        if (isActive) {
            const processType = process;
            const baseRecord = this.getBaseRecord(record);
            const options = {
                action: processType,
                module: record.module ?? '',
                record: baseRecord
            };
            field.loading = true;
            this.processService.submit(processType, options).subscribe((result) => {
                const targetDisplay = result?.data?.value ?? null;
                field.loading = false;
                if (targetDisplay === null) {
                    this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
                    return;
                }
                display = targetDisplay;
                data.field.display = display;
            }, (error) => {
                field.loading = false;
                this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
            });
        }
        const resetOn = (action.params && action.params.resetOn) || 'none';
        if (resetOn === display) {
            if (data.field.valueList && data.field.valueList.length) {
                data.field.valueList = [];
            }
            if (data.field.value) {
                data.field.value = '';
            }
        }
    }
    getBaseRecord(record) {
        if (!record) {
            return null;
        }
        this.mapRecordFields(record);
        const baseRecord = {
            id: record.id,
            type: record.type,
            module: record.module,
            attributes: record.attributes,
            acls: record.acls
        };
        return deepClone(baseRecord);
    }
    /**
     * Map staging fields
     */
    mapRecordFields(record) {
        const mappers = this.recordMappers.get(record.module);
        Object.keys(mappers).forEach(key => {
            const mapper = mappers[key];
            mapper.map(record);
        });
    }
    getTriggeringStatus() {
        return ['onValueChange', 'onFieldInitialize'];
    }
    static { this.ɵfac = function DisplayTypeBackendAction_Factory(t) { return new (t || DisplayTypeBackendAction)(i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(ProcessService), i0.ɵɵinject(MessageService), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper), i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DisplayTypeBackendAction, factory: DisplayTypeBackendAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DisplayTypeBackendAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: AsyncActionService }, { type: ProcessService }, { type: MessageService }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }, { type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldLogicManager extends BaseActionManager {
    constructor(displayType, emailPrimarySelectAction, required, updateBaseCurrency, updateCurrency, updateValue, updateFlexRelateModule, updateValueBackend, dislayTypeBackend) {
        super();
        this.actions = {
            edit: {},
            create: {},
            list: {},
            detail: {},
            massupdate: {},
            filter: {}
        };
        displayType.modes.forEach(mode => this.actions[mode][displayType.key] = displayType);
        emailPrimarySelectAction.modes.forEach(mode => this.actions[mode][emailPrimarySelectAction.key] = emailPrimarySelectAction);
        required.modes.forEach(mode => this.actions[mode][required.key] = required);
        updateBaseCurrency.modes.forEach(mode => this.actions[mode][updateBaseCurrency.key] = updateBaseCurrency);
        updateCurrency.modes.forEach(mode => this.actions[mode][updateCurrency.key] = updateCurrency);
        updateFlexRelateModule.modes.forEach(mode => this.actions[mode][updateFlexRelateModule.key] = updateFlexRelateModule);
        updateValue.modes.forEach(mode => this.actions[mode][updateValue.key] = updateValue);
        updateValueBackend.modes.forEach(mode => this.actions[mode][updateValueBackend.key] = updateValueBackend);
        dislayTypeBackend.modes.forEach(mode => this.actions[mode][dislayTypeBackend.key] = dislayTypeBackend);
    }
    /**
     * Run logic for the given field
     * @param {object} field
     * @param {object} mode
     * @param {object} record
     * @param triggeringStatus
     */
    runLogic(field, mode, record, triggeringStatus = '') {
        if (!field.logic) {
            return;
        }
        const actions = Object.keys(field.logic).map(key => field.logic[key]);
        const modeActions = this.parseModeActions(actions, mode, triggeringStatus);
        const context = {
            record,
            field,
            module: record.module
        };
        modeActions.forEach(action => {
            this.runAction(action, mode, context);
        });
    }
    /**
     * Run the action using given context
     * @param action
     * @param mode
     * @param context
     */
    runAction(action, mode, context = null) {
        this.runFrontEndAction(action, mode, context);
    }
    /**
     * Run front end action
     * @param {object} action
     * @param {object} mode
     * @param {object} context
     */
    runFrontEndAction(action, mode, context = null) {
        const data = this.buildActionData(action, context);
        this.run(action, mode, data);
    }
    /**
     * Get module name
     * @param {object} context
     */
    getModuleName(context) {
        return context.module;
    }
    buildActionData(action, context) {
        return {
            field: context.field,
            record: (context && context.record) || null,
        };
    }
    /**
     * Parse mode actions
     * @param declaredActions
     * @param mode
     * @param triggeringStatus
     */
    parseModeActions(declaredActions, mode, triggeringStatus) {
        if (!declaredActions) {
            return [];
        }
        const availableActions = {
            list: [],
            detail: [],
            edit: [],
            create: [],
            massupdate: [],
            filter: [],
        };
        if (declaredActions && declaredActions.length) {
            declaredActions.forEach(action => {
                if (!action.modes || !action.modes.length) {
                    return;
                }
                action.modes.forEach(actionMode => {
                    if (!availableActions[actionMode] && !action.asyncProcess) {
                        return;
                    }
                    availableActions[actionMode].push(action);
                });
            });
        }
        const actions = [];
        const defaultTriggeringStatus = ['onValueChange'];
        availableActions[mode].forEach(action => {
            const frontendActionTriggeringStatus = this?.actions[mode][action.key]?.getTriggeringStatus() ?? null;
            const actionTriggeringStatus = action?.triggeringStatus ?? frontendActionTriggeringStatus ?? defaultTriggeringStatus;
            if (triggeringStatus && !actionTriggeringStatus.includes(triggeringStatus)) {
                return;
            }
            actions.push(action);
        });
        return actions;
    }
    static { this.ɵfac = function FieldLogicManager_Factory(t) { return new (t || FieldLogicManager)(i0.ɵɵinject(FieldLogicDisplayTypeAction), i0.ɵɵinject(EmailPrimarySelectAction), i0.ɵɵinject(RequiredAction), i0.ɵɵinject(UpdateBaseCurrencyAction), i0.ɵɵinject(UpdateCurrencyAction), i0.ɵɵinject(UpdateValueAction), i0.ɵɵinject(UpdateFlexRelateModuleAction), i0.ɵɵinject(UpdateValueBackendAction), i0.ɵɵinject(DisplayTypeBackendAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldLogicManager, factory: FieldLogicManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLogicManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FieldLogicDisplayTypeAction }, { type: EmailPrimarySelectAction }, { type: RequiredAction }, { type: UpdateBaseCurrencyAction }, { type: UpdateCurrencyAction }, { type: UpdateValueAction }, { type: UpdateFlexRelateModuleAction }, { type: UpdateValueBackendAction }, { type: DisplayTypeBackendAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldLogicDisplayActionHandler extends ActionHandler {
    shouldDisplay(data) {
        return true;
    }
    ;
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DisplayTypeAction extends FieldLogicDisplayActionHandler {
    constructor(activeFieldsChecker) {
        super();
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'displayType';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return true;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return true;
        }
        return this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
    }
    static { this.ɵfac = function DisplayTypeAction_Factory(t) { return new (t || DisplayTypeAction)(i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DisplayTypeAction, factory: DisplayTypeAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DisplayTypeAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldLogicDisplayManager extends BaseActionManager {
    constructor(displayType) {
        super();
        displayType.modes.forEach(mode => this.actions[mode][displayType.key] = displayType);
    }
    runAll(field, record, mode) {
        let toDisplay = 'show';
        if (!field.displayLogic) {
            return;
        }
        const validModeLogic = Object.values(field.displayLogic).filter(logic => {
            const allowedModes = logic['modes'] ?? [];
            return !!(allowedModes.length && allowedModes.includes(mode));
        });
        if (!validModeLogic || !validModeLogic.length) {
            field.display = toDisplay;
            return;
        }
        let defaultDisplay = field.defaultDisplay ?? 'show';
        let targetDisplay = 'none';
        if (defaultDisplay === 'none') {
            targetDisplay = 'show';
        }
        const context = {
            record,
            field,
            module: record.module
        };
        const isActive = validModeLogic.some(logic => {
            const data = this.buildActionData(logic, context);
            return this.actions[mode][logic.key].run(data, logic);
        });
        if (isActive) {
            defaultDisplay = targetDisplay;
        }
        toDisplay = defaultDisplay;
        if (defaultDisplay === 'show') {
            toDisplay = 'show';
        }
        field.display = toDisplay;
    }
    buildActionData(action, context) {
        return {
            field: context.field,
            record: (context && context.record) || null,
        };
    }
    static { this.ɵfac = function FieldLogicDisplayManager_Factory(t) { return new (t || FieldLogicDisplayManager)(i0.ɵɵinject(DisplayTypeAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldLogicDisplayManager, factory: FieldLogicDisplayManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLogicDisplayManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DisplayTypeAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldHandler {
    initDefaultValue(field, record) {
        if (field.defaultValueInitialized) {
            return;
        }
        const defaultValue = field?.default ?? field?.definition?.default ?? null;
        if (!field.value && defaultValue) {
            field.value = defaultValue;
            field?.formControl?.setValue(defaultValue);
            field.defaultValueInitialized = true;
        }
        else if (field.value === null) {
            field.value = '';
        }
    }
    static { this.ɵfac = function BaseFieldHandler_Factory(t) { return new (t || BaseFieldHandler)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseFieldHandler, factory: BaseFieldHandler.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFieldHandler, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateFieldHandler extends BaseFieldHandler {
    constructor(processService, messages) {
        super();
        this.processService = processService;
        this.messages = messages;
    }
    initDefaultValue(field, record) {
        if (field.defaultValueInitialized) {
            return;
        }
        let defaultValue = field?.default ?? field?.definition?.default ?? null;
        let displayDefault = field?.definition?.display_default ?? null;
        if (!defaultValue && !displayDefault) {
            field.defaultValueInitialized = true;
            return;
        }
        if (typeof defaultValue !== "string" && typeof displayDefault !== "string") {
            return;
        }
        if (defaultValue && typeof defaultValue !== "string") {
            super.initDefaultValue(field, record);
            return;
        }
        const processType = 'calculate-date-default';
        const options = {
            action: processType,
            module: record.module ?? '',
            field: field.name,
            displayDefault: displayDefault
        };
        field.loading = true;
        this.processService.submit(processType, options).pipe(take(1)).subscribe((result) => {
            const value = result?.data?.value ?? null;
            field.loading = false;
            if (value === null) {
                this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
                return;
            }
            this.updateValue(field, value.toString(), record);
            field.defaultValueInitialized = true;
        });
    }
    updateValue(field, value, record) {
        field.value = value.toString();
        field.formControl.setValue(value);
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function DateFieldHandler_Factory(t) { return new (t || DateFieldHandler)(i0.ɵɵinject(ProcessService), i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateFieldHandler, factory: DateFieldHandler.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateFieldHandler, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ProcessService }, { type: MessageService }]; }, null); })();

class MultiEnumFieldHandler extends BaseFieldHandler {
    initDefaultValue(field, record) {
        if (field.defaultValueInitialized) {
            return;
        }
        let defaultValue = field?.default ?? field?.definition?.default ?? null;
        if (!defaultValue) {
            field.defaultValueInitialized = true;
            return;
        }
        if (typeof defaultValue !== "string") {
            return;
        }
        defaultValue = trimStart(defaultValue, '^');
        defaultValue = trimEnd(defaultValue, '^');
        const defaultValues = defaultValue.split("^,^");
        if (!defaultValue) {
            field.defaultValueInitialized = true;
            return;
        }
        if (defaultValues && defaultValues.length) {
            field.valueList = defaultValues;
        }
        field.defaultValueInitialized = true;
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵMultiEnumFieldHandler_BaseFactory; return function MultiEnumFieldHandler_Factory(t) { return (ɵMultiEnumFieldHandler_BaseFactory || (ɵMultiEnumFieldHandler_BaseFactory = i0.ɵɵgetInheritedFactory(MultiEnumFieldHandler)))(t || MultiEnumFieldHandler); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MultiEnumFieldHandler, factory: MultiEnumFieldHandler.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumFieldHandler, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DefaultFieldHandler extends BaseFieldHandler {
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵDefaultFieldHandler_BaseFactory; return function DefaultFieldHandler_Factory(t) { return (ɵDefaultFieldHandler_BaseFactory || (ɵDefaultFieldHandler_BaseFactory = i0.ɵɵgetInheritedFactory(DefaultFieldHandler)))(t || DefaultFieldHandler); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DefaultFieldHandler, factory: DefaultFieldHandler.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DefaultFieldHandler, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldHandlerRegistry extends BaseServiceRegistry {
    constructor(defaultFieldHandler, dateFieldHandler, multienumFieldHandler) {
        super();
        this.defaultFieldHandler = defaultFieldHandler;
        this.dateFieldHandler = dateFieldHandler;
        this.multienumFieldHandler = multienumFieldHandler;
        this.defaultMap = {};
        this.defaultMap = {
            'default': defaultFieldHandler,
            'date': dateFieldHandler,
            'multienum': multienumFieldHandler
        };
        this.initDefault();
    }
    initDefault() {
        Object.keys(this.getDefaultMap()).forEach(type => {
            this.register('default', type, this.getDefaultMap()[type]);
        });
    }
    getDefaultMap() {
        return this.defaultMap ?? {};
    }
    static { this.ɵfac = function FieldHandlerRegistry_Factory(t) { return new (t || FieldHandlerRegistry)(i0.ɵɵinject(DefaultFieldHandler), i0.ɵɵinject(DateFieldHandler), i0.ɵɵinject(MultiEnumFieldHandler)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldHandlerRegistry, factory: FieldHandlerRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldHandlerRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DefaultFieldHandler }, { type: DateFieldHandler }, { type: MultiEnumFieldHandler }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldComponent {
    get mode() {
        return this._mode;
    }
    set mode(value) {
        this._mode = value;
        this.modeState.next(this._mode);
    }
    constructor(typeFormatter, logic, logicDisplay) {
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.originalMode = '';
        this.klass = null;
        this._mode = '';
        this.dependentFields = {};
        this.dependentAttributes = [];
        this.subs = [];
        this.validateOnlyOnSubmit = false;
        this.isInvalid = signal(false);
        this.modeState = new BehaviorSubject('');
        this.mode$ = this.modeState.asObservable();
        this.fieldHandlerRegistry = inject(FieldHandlerRegistry);
    }
    ngOnInit() {
        this.baseInit();
        if (!this.originalMode) {
            this.originalMode = this.mode;
        }
        const defaultValueModes = this?.field?.defaultValueModes ?? [];
        if (defaultValueModes.includes(this.originalMode)) {
            const fieldHandler = this.fieldHandlerRegistry.get(this.record.module, this.field.type);
            fieldHandler.initDefaultValue(this.field, this.record);
        }
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    baseInit() {
        this.initDependencyHandlers();
        this.validateOnlyOnSubmit = this.record?.metadata?.validateOnlyOnSubmit;
        if (this.record?.validationTriggered) {
            this.isInvalid = computed(() => {
                if (this.record?.metadata?.validateOnlyOnSubmit && this.record?.validationTriggered() && this.field.formControl?.invalid) {
                    return true;
                }
                return false;
            });
        }
    }
    /**
     * Calculate and init dependency handlers
     */
    initDependencyHandlers() {
        if (!this.record) {
            return;
        }
        const fieldKeys = (this.record.fields && Object.keys(this.record.fields)) || [];
        if (fieldKeys.length > 1) {
            this.calculateDependentFields(fieldKeys);
            this.field.previousValue = this.field.value;
            if ((this.dependentFields && Object.keys(this.dependentFields).length) || this.dependentAttributes.length) {
                Object.keys(this.dependentFields).forEach(fieldKey => {
                    const field = this.record.fields[fieldKey] || null;
                    if (!field) {
                        return;
                    }
                    const types = this.dependentFields[fieldKey].type ?? [];
                    if (types.includes('logic')) {
                        this.logic.runLogic(field, this.originalMode, this.record, 'onFieldInitialize');
                    }
                    if (types.includes('displayLogic')) {
                        this.logicDisplay.runAll(field, this.record, this.originalMode);
                    }
                });
            }
            if (this.field.valueChanges$ && ((this.dependentFields && Object.keys(this.dependentFields).length) || this.dependentAttributes.length)) {
                this.subs.push(this.field.valueChanges$.pipe(debounceTime(500)).subscribe((data) => {
                    Object.keys(this.dependentFields).forEach(fieldKey => {
                        const dependentField = this.dependentFields[fieldKey];
                        const field = this.record.fields[fieldKey] || null;
                        if (!field) {
                            return;
                        }
                        if (this.field.previousValue != data.value) {
                            const types = dependentField.type ?? [];
                            if (types.includes('logic')) {
                                this.logic.runLogic(field, this.originalMode, this.record, 'onValueChange');
                            }
                            if (types.includes('displayLogic')) {
                                this.logicDisplay.runAll(field, this.record, this.originalMode);
                            }
                        }
                    });
                    this.field.previousValue = data.value;
                    this.dependentAttributes.forEach(dependency => {
                        const field = this.record.fields[dependency.field] || {};
                        const attribute = (field && field.attributes && field.attributes[dependency.attribute]) || null;
                        if (!attribute) {
                            return;
                        }
                        this.logic.runLogic(attribute, this.mode, this.record, 'onValueChange');
                    });
                }));
            }
        }
    }
    /**
     * Calculate dependent fields
     * @param {array} fieldKeys
     */
    calculateDependentFields(fieldKeys) {
        fieldKeys.forEach(key => {
            if (this.field.source === 'field' || this.field.source === 'groupField') {
                this.addFieldDependency(key, this.dependentFields, this.dependentAttributes);
                return;
            }
            if (this.field.source === 'attribute') {
                this.addAttributeDependency(key, this.dependentFields, this.dependentAttributes);
                return;
            }
        });
    }
    /**
     * Add field dependency
     * @param {string} fieldKey
     * @param {array} dependentFields
     * @param {object} dependentAttributes
     */
    addFieldDependency(fieldKey, dependentFields, dependentAttributes) {
        const field = this.record.fields[fieldKey];
        const name = this.field.name || this.field.definition.name || '';
        if (fieldKey === name || !field) {
            return;
        }
        if (field.fieldDependencies && this.isDependencyField(field.fieldDependencies)) {
            dependentFields[fieldKey] = field.fieldDependencies[name];
        }
        const attributeKeys = (field.attributes && Object.keys(field.attributes)) || [];
        attributeKeys.forEach(attributeKey => {
            const attribute = field.attributes[attributeKey];
            if (!attribute || !attribute.fieldDependencies || !attribute.fieldDependencies.length) {
                return;
            }
            if (this.isDependencyField(attribute.fieldDependencies)) {
                dependentAttributes.push({
                    field: fieldKey,
                    attribute: attributeKey,
                    types: dependentFields[name]['types'] ?? []
                });
            }
        });
    }
    /**
     * Check if field is dependency
     * @param dependencies
     * @returns {boolean}
     */
    isDependencyField(dependencies) {
        const name = this.field.name || this.field.definition.name || '';
        return !!(dependencies[name] ?? false);
    }
    /**
     * Add attribute dependency
     * @param {string} fieldKey
     * @param {array} dependentFields
     * @param {object} dependentAttributes
     */
    addAttributeDependency(fieldKey, dependentFields, dependentAttributes) {
        const field = this.record.fields[fieldKey];
        const name = this.field.name || this.field.definition.name || '';
        if (fieldKey === name || !field) {
            return;
        }
        if (field.attributeDependencies && field.attributeDependencies.length && this.isDependencyAttribute(field.attributeDependencies)) {
            dependentFields[name] = field.fieldDependencies[name];
        }
        const attributeKeys = (field.attributes && Object.keys(field.attributes)) || [];
        attributeKeys.forEach(attributeKey => {
            const attribute = field.attributes[attributeKey];
            if (attribute && attribute.attributeDependencies && attribute.attributeDependencies.length) {
                const hasDependency = this.isDependencyAttribute(attribute.attributeDependencies);
                if (hasDependency) {
                    dependentAttributes.push({
                        field: fieldKey,
                        attribute: attributeKey,
                        types: (dependentFields[name] ?? {})['types'] ?? []
                    });
                }
            }
        });
    }
    /**
     * Check if attribute is dependency
     * @param {object} attributeDependencies
     * @returns {boolean}
     */
    isDependencyAttribute(attributeDependencies) {
        const parentKey = this.field.parentKey || '';
        const name = this.field.name || this.field.definition.name || '';
        return attributeDependencies.some(dependency => parentKey === dependency.field && name === dependency.attribute);
    }
    subscribeValueChanges() {
        if (this.field && this.field.formControl) {
            this.subs.push(this.field.formControl.valueChanges.subscribe(value => {
                if (!isVoid(value)) {
                    value = value.trim();
                }
                else {
                    value = '';
                }
                if (this.typeFormatter && this.field.type) {
                    value = this.toInternalFormat(this.field.type, value);
                }
                this.setFieldValue(value);
            }));
        }
    }
    toInternalFormat(fieldType, value) {
        return this.typeFormatter.toInternalFormat(fieldType, value);
    }
    setFieldValue(newValue) {
        this.field.value = newValue;
    }
    setFormControlValue(newValue) {
        if (isEqual(this.field.formControl.value, newValue)) {
            this.field.formControl.markAsPristine();
            return;
        }
        this.field.formControl.setValue(newValue);
        this.field.formControl.markAsDirty();
    }
    unsubscribeAll() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    static { this.ɵfac = function BaseFieldComponent_Factory(t) { return new (t || BaseFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseFieldComponent, selectors: [["ng-component"]], inputs: { originalMode: "originalMode", field: "field", record: "record", parent: "parent", klass: "klass", mode: "mode" }, decls: 0, vars: 0, template: function BaseFieldComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFieldComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { originalMode: [{
            type: Input
        }], field: [{
            type: Input
        }], record: [{
            type: Input
        }], parent: [{
            type: Input
        }], klass: [{
            type: Input
        }], mode: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PhoneDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    getTelLink(phone) {
        if (!phone) {
            return null;
        }
        return 'tel:' + this.getUnFormatted(phone);
    }
    getUnFormatted(phone) {
        if (!phone) {
            return '';
        }
        return phone.replace(/\s+/g, '');
    }
    static { this.ɵfac = function PhoneDetailFieldComponent_Factory(t) { return new (t || PhoneDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PhoneDetailFieldComponent, selectors: [["scrm-phone-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [[3, "href"]], template: function PhoneDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "a", 0);
            i0.ɵɵtext(1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("href", ctx.getTelLink(ctx.field.value), i0.ɵɵsanitizeUrl);
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate(ctx.field.value);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PhoneDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-phone-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<a [href]=\"getTelLink(field.value)\">{{ field.value }}</a>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseEnumComponent extends BaseFieldComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.selectedValues = [];
        this.valueLabel = '';
        this.options = [];
        this.subs = [];
        this.isDynamicEnum = false;
    }
    ngOnInit() {
        super.ngOnInit();
        const options$ = this?.field?.metadata?.options$ ?? null;
        if (options$) {
            this.subs.push(this.field.metadata.options$.subscribe((options) => {
                this.buildProvidedOptions(options);
                this.initValue();
            }));
            return;
        }
        const options = this?.field?.definition?.options ?? null;
        if (options) {
            this.subs.push(this.languages.vm$.subscribe((strings) => {
                this.buildAppStringListOptions(strings.appListStrings);
                this.initValue();
            }));
        }
        if (!options && !options$) {
            this.initValue();
        }
    }
    ngOnDestroy() {
        this.isDynamicEnum = false;
        this.subs.forEach(sub => sub.unsubscribe());
        this.options = [];
        this.optionsMap = {};
        this.selectedValues = [];
    }
    getInvalidClass() {
        if (this.validateOnlyOnSubmit ? this.isInvalid() : (this.field.formControl.invalid && this.field.formControl.touched)) {
            return 'is-invalid';
        }
        return '';
    }
    buildProvidedOptions(options) {
        this.options = options;
        this.optionsMap = {};
        options.forEach(option => {
            this.optionsMap[option.value] = option.label;
        });
    }
    buildAppStringListOptions(appStrings) {
        this.optionsMap = {};
        this.addExtraOptions();
        if (appStrings && this.field.definition.options && appStrings[this.field.definition.options]) {
            const options = appStrings[this.field.definition.options];
            if (this.options && Object.keys(this.options)) {
                this.optionsMap = { ...this.optionsMap, ...options };
            }
        }
        this.buildOptionsArray(appStrings);
    }
    addExtraOptions() {
        const extraOptions = (this.field.metadata && this.field.metadata.extraOptions) || [];
        extraOptions.forEach((item) => {
            if (isVoid(item.value)) {
                return;
            }
            let label = item.label || '';
            if (item.labelKey) {
                label = this.languages.getFieldLabel(item.labelKey);
            }
            this.optionsMap[item.value] = label;
        });
    }
    buildOptionsArray(appStrings) {
        this.options = [];
        Object.keys(this.optionsMap).forEach(key => {
            const isOptionEmpty = isEmptyString(this.optionsMap[key]);
            if (isOptionEmpty && this.isSkipEmptyMode()) {
                return;
            }
            if (isOptionEmpty && !this.addEmptyStringOption()) {
                return;
            }
            this.options.push({
                value: key,
                label: this.optionsMap[key]
            });
        });
        if (this.isDynamicEnum) {
            this.buildDynamicEnumOptions(appStrings);
        }
    }
    addEmptyStringOption() {
        return this.field.type !== 'multienum';
    }
    isSkipEmptyMode() {
        return this.mode === 'massupdate' || this.mode === 'filter';
    }
    initValue() {
        this.selectedValues = [];
        if (this.field.criteria) {
            this.initValueLabel();
            return;
        }
        if (typeof this.field.value !== 'string') {
            return;
        }
        if (!this.optionsMap) {
            return;
        }
        if (typeof this.optionsMap[this.field.value] !== 'string') {
            return;
        }
        this.initValueLabel();
    }
    initValueLabel() {
        const fieldValue = this.field.value || this.field.criteria?.target || undefined;
        if (fieldValue !== undefined) {
            this.valueLabel = this.optionsMap[fieldValue];
            this.selectedValues.push({
                value: fieldValue,
                label: this.valueLabel
            });
        }
    }
    /**
     *  Initialize the default value for the enum
     *
     *  @returns {void}
     *  @description set default enum value, if defined in vardefs
     * */
    initEnumDefault() {
        if (!isEmptyString(this.record?.id)) {
            this.field?.formControl.setValue('');
            return;
        }
        let defaultVal = this?.field?.default ?? this?.field?.definition?.default ?? null;
        if (typeof defaultVal === 'string') {
            defaultVal = defaultVal.trim();
        }
        if (!defaultVal) {
            this.field.formControl.setValue('');
            return;
        }
        this.selectedValues.push({
            value: defaultVal,
            label: this.optionsMap[defaultVal]
        });
        this.initEnumDefaultFieldValues(defaultVal);
    }
    initEnumDefaultFieldValues(defaultVal) {
        if (this.field.type === 'multienum') {
            const defaultValues = this.selectedValues.map(option => option.value);
            this.field.valueList = defaultValues;
            this.field.formControl.setValue(defaultValues);
        }
        else {
            this.field.value = defaultVal;
            this.field.formControl.setValue(defaultVal);
        }
        this.field.formControl.markAsDirty();
    }
    checkAndInitAsDynamicEnum() {
        const definition = (this.field && this.field.definition) || {};
        const dynamic = (definition && definition.dynamic) || false;
        const parentEnumKey = (definition && definition.parentenum) || '';
        const fields = (this.record && this.record.fields) || null;
        if (dynamic && parentEnumKey && fields) {
            this.isDynamicEnum = true;
            const parentEnum = fields[parentEnumKey];
            if (parentEnum) {
                this.subscribeToParentValueChanges(parentEnum);
            }
        }
    }
    buildDynamicEnumOptions(appStrings) {
        const parentEnum = this.record.fields[this.field.definition.parentenum];
        if (parentEnum) {
            const parentOptionMap = appStrings[parentEnum.definition.options];
            if (parentOptionMap && Object.keys(parentOptionMap).length !== 0) {
                this.mappedOptions = this.createParentChildOptionsMap(parentOptionMap, this.options);
                let parentValues = [];
                if (parentEnum.definition.type === 'multienum') {
                    parentValues = parentEnum.valueList;
                }
                else {
                    parentValues.push(parentEnum.value);
                }
                this.options = this.filterMatchingOptions(parentValues);
                if (parentValues && parentValues.length) {
                    this.setValueToAvailableOption();
                }
            }
        }
    }
    filterMatchingOptions(values) {
        let filteredOptions = [];
        if (!values || !values.length) {
            return [];
        }
        values.forEach(value => {
            if (!this.mappedOptions[value]) {
                return;
            }
            filteredOptions = filteredOptions.concat([...this.mappedOptions[value]]);
        });
        return filteredOptions;
    }
    createParentChildOptionsMap(parentOptions, childOptions) {
        const mappedOptions = {};
        Object.keys(parentOptions).forEach(key => {
            mappedOptions[key] = childOptions.filter(option => String(option.value).startsWith(key));
        });
        return mappedOptions;
    }
    subscribeToParentValueChanges(parentEnum) {
        if (parentEnum.formControl) {
            this.subs.push(parentEnum.formControl.valueChanges.subscribe(values => {
                if (typeof values === 'string') {
                    values = [values];
                }
                // Rebuild available enum options
                this.options = this.filterMatchingOptions(values);
                this.setValueToAvailableOption();
                this.initValue();
            }));
        }
    }
    setValueToAvailableOption() {
        if (!this?.options?.length) {
            this.field.value = '';
            this.field.formControl.setValue('');
            return;
        }
        if (!this.options.some(option => option.value === this.field.value)) {
            this.field.value = this.options[0].value;
            this.field.formControl.setValue(this.options[0].value);
        }
    }
    buildOptionFromValue(value) {
        const option = { value: '', label: '' };
        if (isNull(value)) {
            return option;
        }
        option.value = (typeof value !== 'string' ? JSON.stringify(value) : value).trim();
        option.label = option.value;
        const valueLabel = this.optionsMap[option.value] ?? option.label;
        if (isObject(valueLabel)) {
            return option;
        }
        option.label = (typeof valueLabel !== 'string' ? JSON.stringify(valueLabel) : valueLabel).trim();
        return option;
    }
    static { this.ɵfac = function BaseEnumComponent_Factory(t) { return new (t || BaseEnumComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseEnumComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseEnumComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseEnumComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseMultiEnumComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    subscribeValueChanges() {
    }
    initValue() {
        const fieldValueList = this.field.valueList;
        if (isVoid(fieldValueList) || isEmpty(fieldValueList)) {
            return;
        }
        this.updateInternalState(fieldValueList);
    }
    updateInternalState(value = []) {
        const valueArray = isArray(value) ? value : [value];
        this.selectedValues = valueArray.map(valueElement => this.buildOptionFromValue(valueElement));
        this.selectedValues = uniqBy(this.selectedValues, 'value');
        this.syncSelectedValuesWithForm();
    }
    syncSelectedValuesWithForm() {
        const selectedValuesValueMap = this.selectedValues.map(selectedValue => selectedValue.value);
        if (!isEqual(this.field.valueList, selectedValuesValueMap)) {
            this.setFormControlValue(selectedValuesValueMap);
        }
        return selectedValuesValueMap;
    }
    static { this.ɵfac = function BaseMultiEnumComponent_Factory(t) { return new (t || BaseMultiEnumComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMultiEnumComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseMultiEnumComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMultiEnumComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$G = ["multiSelect"];
function MultiEnumFilterFieldComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 6);
} }
function MultiEnumFilterFieldComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 7);
} }
function MultiEnumFilterFieldComponent_ng_template_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 8);
} }
class MultiEnumFilterFieldComponent extends BaseMultiEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay, screenSize, systemConfigStore, primengConfig) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.primengConfig = primengConfig;
        this.placeholderLabel = '';
        this.selectedItemsLabel = '';
        this.emptyFilterLabel = '';
        this.maxSelectedLabels = 20;
        this.selectAll = false;
    }
    ngOnInit() {
        this.field.valueList = [];
        if (this.field.criteria.values && this.field.criteria.values.length > 0) {
            this.field.valueList = this.field.criteria.values;
        }
        const maxSelectedLabelsForDisplay = this.systemConfigStore.getUi('multiselect_max_number');
        this.screenSize.screenSize$
            .pipe(take(1))
            .subscribe((screenSize) => {
            this.maxSelectedLabels = maxSelectedLabelsForDisplay[screenSize] || this.maxSelectedLabels;
        });
        this.getTranslatedLabels();
        super.ngOnInit();
        this.primengConfig.ripple = true;
    }
    onAdd() {
        const value = this.selectedValues.map(option => option.value);
        this.field.valueList = value;
        this.field.formControl.setValue(value);
        this.field.formControl.markAsDirty();
        this.field.criteria.operator = '=';
        this.field.criteria.values = value;
        this.calculateSelectAll();
    }
    onRemove() {
        let value = this.selectedValues.map(option => option.value);
        if (!value) {
            value = [];
        }
        this.field.valueList = value;
        this.field.formControl.setValue(value);
        this.field.formControl.markAsDirty();
        this.field.criteria.operator = '=';
        this.field.criteria.values = value;
        this.calculateSelectAll();
    }
    onClear() {
        this.selectedValues = [];
        this.multiSelect.filterValue = '';
        this.onRemove();
    }
    onPanelShow() {
        this.multiSelect.filterInputChild.nativeElement.focus();
        this.multiSelect.filterValue = '';
        this.calculateSelectAll();
    }
    onFilter() {
        this.calculateSelectAll();
    }
    getPlaceholderLabel() {
        return this.languages.getAppString('LBL_SELECT_ITEM') || '';
    }
    onSelectAll(event) {
        this.selectAll = event.checked;
        if (this.selectAll) {
            if (this.multiSelect.visibleOptions() && this.multiSelect.visibleOptions().length) {
                this.selectedValues = this.multiSelect.visibleOptions();
            }
            else {
                this.selectedValues = this.options;
            }
            this.onAdd();
        }
        else {
            this.selectedValues = [];
            this.onRemove();
        }
    }
    getTranslatedLabels() {
        this.placeholderLabel = this.languages.getAppString('LBL_SELECT_ITEM') || '';
        this.selectedItemsLabel = this.languages.getAppString('LBL_ITEMS_SELECTED') || '';
        this.emptyFilterLabel = this.languages.getAppString('ERR_SEARCH_NO_RESULTS') || '';
    }
    addEmptyStringOption() {
        return false;
    }
    calculateSelectAll() {
        const visibleOptions = this?.multiSelect?.visibleOptions() ?? [];
        const selectedValuesKeys = (this?.selectedValues ?? []).map(item => item.value);
        if (!visibleOptions.length || !selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        if (visibleOptions.length > selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        this.selectAll = visibleOptions.every(item => selectedValuesKeys.includes(item.value));
    }
    static { this.ɵfac = function MultiEnumFilterFieldComponent_Factory(t) { return new (t || MultiEnumFilterFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(i7.PrimeNGConfig)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MultiEnumFilterFieldComponent, selectors: [["scrm-multienum-filter"]], viewQuery: function MultiEnumFilterFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$G, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.multiSelect = _t.first);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 14, consts: [[1, "d-flex", "align-items-center"], [3, "options", "ngModel", "optionLabel", "placeholder", "selectedItemsLabel", "emptyFilterMessage", "maxSelectedLabels", "styleClass", "showToggleAll", "selectAll", "autoOptionFocus", "autofocusFilter", "showClear", "focusOnHover", "ngModelChange", "onChange", "onSelectAllChange", "onRemove", "onPanelShow", "onFilter", "onClear"], ["multiSelect", ""], ["pTemplate", "dropdownicon"], ["pTemplate", "filtericon"], ["pTemplate", "checkicon"], ["image", "down_carret"], ["image", "search"], ["image", "checkbox_cross"]], template: function MultiEnumFilterFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "p-multiSelect", 1, 2);
            i0.ɵɵlistener("ngModelChange", function MultiEnumFilterFieldComponent_Template_p_multiSelect_ngModelChange_1_listener($event) { return ctx.selectedValues = $event; })("onChange", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onChange_1_listener() { return ctx.onAdd(); })("onSelectAllChange", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onSelectAllChange_1_listener($event) { return ctx.onSelectAll($event); })("onRemove", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onRemove_1_listener() { return ctx.onRemove(); })("onPanelShow", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onPanelShow_1_listener() { return ctx.onPanelShow(); })("onFilter", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onFilter_1_listener() { return ctx.onFilter(); })("onClear", function MultiEnumFilterFieldComponent_Template_p_multiSelect_onClear_1_listener() { return ctx.onClear(); });
            i0.ɵɵtemplate(3, MultiEnumFilterFieldComponent_ng_template_3_Template, 1, 0, "ng-template", 3);
            i0.ɵɵtemplate(4, MultiEnumFilterFieldComponent_ng_template_4_Template, 1, 0, "ng-template", 4);
            i0.ɵɵtemplate(5, MultiEnumFilterFieldComponent_ng_template_5_Template, 1, 0, "ng-template", 5);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("options", ctx.options)("ngModel", ctx.selectedValues)("optionLabel", "label")("placeholder", ctx.placeholderLabel)("selectedItemsLabel", "{0} " + ctx.selectedItemsLabel)("emptyFilterMessage", ctx.emptyFilterLabel)("maxSelectedLabels", ctx.maxSelectedLabels)("styleClass", "w-100 " + ctx.getInvalidClass())("showToggleAll", true)("selectAll", ctx.selectAll)("autoOptionFocus", false)("autofocusFilter", true)("showClear", true)("focusOnHover", true);
        } }, dependencies: [i5$1.NgControlStatus, i5$1.NgModel, ImageComponent, i10.MultiSelect, i7.PrimeTemplate], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumFilterFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-multienum-filter', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"d-flex align-items-center\">\n    <p-multiSelect\n        #multiSelect\n        [options]=\"options\"\n        [(ngModel)]=\"selectedValues\"\n        [optionLabel]=\"'label'\"\n        (onChange)=\"onAdd()\"\n        (onSelectAllChange)=\"onSelectAll($event)\"\n        (onRemove)=\"onRemove()\"\n        (onPanelShow)=\"onPanelShow()\"\n        (onFilter)=\"onFilter()\"\n        [placeholder]=\"placeholderLabel\"\n        [selectedItemsLabel]=\"'{0} ' + selectedItemsLabel\"\n        [emptyFilterMessage]=\"emptyFilterLabel\"\n        [maxSelectedLabels]=\"maxSelectedLabels\"\n        [styleClass]=\"'w-100 ' + getInvalidClass()\"\n        [showToggleAll]=\"true\"\n        [selectAll]=\"selectAll\"\n        [autoOptionFocus]=\"false\"\n        [autofocusFilter]=\"true\"\n        [showClear]=\"true\"\n        (onClear)=\"onClear()\"\n        [focusOnHover]=\"true\"\n    >\n        <ng-template pTemplate=\"dropdownicon\">\n            <scrm-image image=\"down_carret\"></scrm-image>\n        </ng-template>\n        <ng-template pTemplate=\"filtericon\">\n            <scrm-image image=\"search\"></scrm-image>\n        </ng-template>\n        <ng-template pTemplate=\"checkicon\">\n            <scrm-image image=\"checkbox_cross\"></scrm-image>\n        </ng-template>\n\n    </p-multiSelect>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }, { type: i7.PrimeNGConfig }]; }, { multiSelect: [{
            type: ViewChild,
            args: ['multiSelect']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EnumDetailFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function EnumDetailFieldComponent_Factory(t) { return new (t || EnumDetailFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EnumDetailFieldComponent, selectors: [["scrm-enum-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function EnumDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.valueLabel, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EnumDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-enum-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{valueLabel}}\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EnumDetailFieldModule {
    static { this.ɵfac = function EnumDetailFieldModule_Factory(t) { return new (t || EnumDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: EnumDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EnumDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [EnumDetailFieldComponent],
                exports: [EnumDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EnumDetailFieldModule, { declarations: [EnumDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [EnumDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseNameComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    getNameField(field, record) {
        if (!field.value || !record.attributes) {
            return;
        }
        const format = field.value.split(' ');
        const groupField = [];
        format.forEach(item => {
            if (record.attributes[item]) {
                groupField.push(record.attributes[item]);
            }
        });
        return groupField.join(' ');
    }
    static { this.ɵfac = function BaseNameComponent_Factory(t) { return new (t || BaseNameComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseNameComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseNameComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseNameComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FullNameDetailFieldsComponent extends BaseNameComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.data = this.getNameField(this.field, this.record);
    }
    static { this.ɵfac = function FullNameDetailFieldsComponent_Factory(t) { return new (t || FullNameDetailFieldsComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FullNameDetailFieldsComponent, selectors: [["scrm-fullname-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function FullNameDetailFieldsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.data, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FullNameDetailFieldsComponent, [{
        type: Component,
        args: [{ selector: 'scrm-fullname-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{this.data}}\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FullNameDetailFieldsModule {
    static { this.ɵfac = function FullNameDetailFieldsModule_Factory(t) { return new (t || FullNameDetailFieldsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FullNameDetailFieldsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FullNameDetailFieldsModule, [{
        type: NgModule,
        args: [{
                declarations: [FullNameDetailFieldsComponent],
                exports: [FullNameDetailFieldsComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FullNameDetailFieldsModule, { declarations: [FullNameDetailFieldsComponent], imports: [CommonModule], exports: [FullNameDetailFieldsComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function VarcharDetailFieldComponent_Factory(t) { return new (t || VarcharDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VarcharDetailFieldComponent, selectors: [["scrm-varchar-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function VarcharDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.field.value, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-varchar-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{field.value}}\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UrlDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    get target() {
        if (this.field.metadata && this.field.metadata.target) {
            return this.field.metadata.target;
        }
        return '_blank';
    }
    static { this.ɵfac = function UrlDetailFieldComponent_Factory(t) { return new (t || UrlDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: UrlDetailFieldComponent, selectors: [["scrm-url-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[3, "target", "href"]], template: function UrlDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "a", 0);
            i0.ɵɵtext(1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵpropertyInterpolate("href", ctx.field.value, i0.ɵɵsanitizeUrl);
            i0.ɵɵproperty("target", ctx.target);
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate(ctx.field.value);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UrlDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-url-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<a [target]=\"target\" href=\"{{ this.field.value }}\">{{ this.field.value }}</a>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseDateTimeComponent extends BaseFieldComponent {
    constructor(formatter, typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.vm$ = this.formatter.format$;
    }
    getDateTimeFormat() {
        if (this.field?.metadata?.date_time_format) {
            return this.field.metadata.date_time_format;
        }
        return this.formatter.getDateTimeFormat();
    }
    toInternalFormat(fieldType, value) {
        return this.formatter.toInternalFormat(value, { fromFormat: this.getDateTimeFormat() });
    }
    static { this.ɵfac = function BaseDateTimeComponent_Factory(t) { return new (t || BaseDateTimeComponent)(i0.ɵɵdirectiveInject(DatetimeFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseDateTimeComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseDateTimeComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseDateTimeComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DatetimeFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseDateComponent extends BaseDateTimeComponent {
    constructor(formatter, typeFormatter, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    getDateFormat() {
        if (this.field?.metadata?.date_time_format) {
            return this.field?.metadata?.date_time_format ?? '';
        }
        return this.formatter.getDateFormat();
    }
    toInternalFormat(fieldType, value) {
        return this.formatter.toInternalFormat(value, { fromFormat: this.getDateFormat() });
    }
    static { this.ɵfac = function BaseDateComponent_Factory(t) { return new (t || BaseDateComponent)(i0.ɵɵdirectiveInject(DatetimeFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseDateComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseDateComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseDateComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DatetimeFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DateDetailFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "date");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r0.field.value, ctx_r0.getDateFormat()), "\n");
} }
class DateDetailFieldComponent extends BaseDateComponent {
    constructor(formatter, typeFormatter, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function DateDetailFieldComponent_Factory(t) { return new (t || DateDetailFieldComponent)(i0.ɵɵdirectiveInject(DateFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateDetailFieldComponent, selectors: [["scrm-date-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[4, "ngIf"]], template: function DateDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, DateDetailFieldComponent_ng_container_0_Template, 3, 4, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe, i2.DatePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-date-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    {{field.value | date:getDateFormat()}}\n</ng-container>\n" }]
    }], function () { return [{ type: DateFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateDetailFieldModule {
    static { this.ɵfac = function DateDetailFieldModule_Factory(t) { return new (t || DateDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateDetailFieldComponent],
                exports: [DateDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateDetailFieldModule, { declarations: [DateDetailFieldComponent], imports: [CommonModule], exports: [DateDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FormatCurrencyPipe {
    constructor(formatter) {
        this.formatter = formatter;
    }
    transform(value, options = null) {
        return this.formatter.toUserFormat(value, options);
    }
    static { this.ɵfac = function FormatCurrencyPipe_Factory(t) { return new (t || FormatCurrencyPipe)(i0.ɵɵdirectiveInject(CurrencyFormatter, 16)); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "formatCurrency", type: FormatCurrencyPipe, pure: true }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormatCurrencyPipe, [{
        type: Pipe,
        args: [{
                name: 'formatCurrency'
            }]
    }], function () { return [{ type: CurrencyFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FormatCurrencyModule {
    static { this.ɵfac = function FormatCurrencyModule_Factory(t) { return new (t || FormatCurrencyModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FormatCurrencyModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormatCurrencyModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    FormatCurrencyPipe
                ],
                exports: [
                    FormatCurrencyPipe
                ],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FormatCurrencyModule, { declarations: [FormatCurrencyPipe], imports: [CommonModule], exports: [FormatCurrencyPipe] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseNumberComponent extends BaseFieldComponent {
    constructor(userPreferences, systemConfig, typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.userPreferences = userPreferences;
        this.systemConfig = systemConfig;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.preferences$ = this.userPreferences.userPreferences$;
        this.configs$ = this.systemConfig.configs$;
        this.vm$ = this.configs$.pipe(combineLatestWith(this.preferences$), map(([configs, preferences]) => ({
            configs,
            preferences,
        })));
    }
    get format() {
        if (!this.field.metadata) {
            return true;
        }
        return this.field.metadata.format !== false;
    }
    static { this.ɵfac = function BaseNumberComponent_Factory(t) { return new (t || BaseNumberComponent)(i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseNumberComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseNumberComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseNumberComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: UserPreferenceStore }, { type: SystemConfigStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function CurrencyDetailFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "formatCurrency");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r0.getCurrencyValue(), ctx_r0.getOptions()), "\n");
} }
class CurrencyDetailFieldComponent extends BaseNumberComponent {
    constructor(userPreferences, systemConfig, typeFormatter, logic, currencyService, logicDisplay) {
        super(userPreferences, systemConfig, typeFormatter, logic, logicDisplay);
        this.userPreferences = userPreferences;
        this.systemConfig = systemConfig;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.currencyService = currencyService;
        this.logicDisplay = logicDisplay;
    }
    getOptions() {
        let options = {};
        if (this.field && this.field.metadata && this.field.metadata.digits !== null && isFinite(this.field.metadata.digits)) {
            options = {
                digits: this.field.metadata.digits
            };
        }
        const isBase = this.currencyService.isBase(this.field);
        let currencyId = this.currencyService.getCurrencyId(this.record);
        if (isBase || currencyId === null) {
            currencyId = this.currencyService.getUserCurrency().id;
        }
        options.symbol = this.currencyService.getSymbol(currencyId);
        options.code = this.currencyService.getCode(currencyId);
        return options;
    }
    getCurrencyValue() {
        return this.currencyService.getFieldCurrencyValue(this.field, this.record);
    }
    static { this.ɵfac = function CurrencyDetailFieldComponent_Factory(t) { return new (t || CurrencyDetailFieldComponent)(i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(CurrencyService), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CurrencyDetailFieldComponent, selectors: [["scrm-currency-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[4, "ngIf"]], template: function CurrencyDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, CurrencyDetailFieldComponent_ng_container_0_Template, 3, 4, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe, FormatCurrencyPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-currency-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    {{this.getCurrencyValue() | formatCurrency:getOptions()}}\n</ng-container>\n" }]
    }], function () { return [{ type: UserPreferenceStore }, { type: SystemConfigStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: CurrencyService }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CurrencyDetailFieldModule {
    static { this.ɵfac = function CurrencyDetailFieldModule_Factory(t) { return new (t || CurrencyDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CurrencyDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormatCurrencyModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [CurrencyDetailFieldComponent],
                exports: [CurrencyDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormatCurrencyModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CurrencyDetailFieldModule, { declarations: [CurrencyDetailFieldComponent], imports: [CommonModule,
        FormatCurrencyModule], exports: [CurrencyDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TextDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    get rows() {
        if (this.field.metadata && this.field.metadata.rows) {
            return this.field.metadata.rows;
        }
        return 6;
    }
    get cols() {
        if (this.field.metadata && this.field.metadata.cols) {
            return this.field.metadata.cols;
        }
        return 20;
    }
    static { this.ɵfac = function TextDetailFieldComponent_Factory(t) { return new (t || TextDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TextDetailFieldComponent, selectors: [["scrm-text-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [["readonly", "", 1, "detail-pre-styling"]], template: function TextDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "pre", 0);
            i0.ɵɵtext(1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate(ctx.field.value);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-text-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<pre readonly class=\"detail-pre-styling\">{{field.value}}</pre>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharEditFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    static { this.ɵfac = function VarcharEditFieldComponent_Factory(t) { return new (t || VarcharEditFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VarcharEditFieldComponent, selectors: [["scrm-varchar-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 5, consts: [["type", "text", 3, "formControl", "value", "ngClass"]], template: function VarcharEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "input", 0);
        } if (rf & 2) {
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("formControl", ctx.field.formControl)("value", ctx.field.value)("ngClass", ctx.klass);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-varchar-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<input [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n       [formControl]=\"field.formControl\"\n       [value]=\"field.value\"\n       [ngClass]=\"klass\"\n       type=\"text\">\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

class DateTimeModel {
    constructor(init) {
        this.hourStep = 1;
        this.minuteStep = 15;
        this.secondStep = 30;
        this.displaySeconds = false;
        Object.assign(this, init);
    }
    static toDateTimeStruct(formatter, dateString) {
        if (!dateString) {
            return null;
        }
        const dateTimeStruct = formatter.userDateTimeFormatToStruct(dateString);
        if (!dateTimeStruct) {
            return null;
        }
        const { date, time } = dateTimeStruct;
        return new DateTimeModel({
            date: date,
            time: time
        });
    }
    static internalToDateTimeStruct(formatter, dateString) {
        if (!dateString) {
            return null;
        }
        const dateTimeStruct = formatter.internalDateTimeFormatToStruct(dateString);
        if (!dateTimeStruct) {
            return null;
        }
        const { date, time } = dateTimeStruct;
        return new DateTimeModel({
            date: date,
            time: time
        });
    }
    toUserFormat(formatter, options) {
        //prepare datetime string in yyyy-M-d H:m:s format (datetimepicker default)
        const dateString = [this.date.year, this.date.month, this.date.day].join('-');
        const timeString = [this.time.hour, this.time.minute, this.time.second].join(':');
        const datetimeString = [dateString, timeString].join(' ');
        const internalDateTimeString = formatter.toInternalFormat(datetimeString, { fromFormat: 'yyyy-M-d H:m:s' });
        //convert from yyyy-M-d H:m:s format to user format
        return formatter.toUserFormat(internalDateTimeString, { ...options, fromFormat: 'yyyy-M-d H:m:s' });
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DateTimeEditFieldComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div")(1, "div")(2, "ngb-datepicker", 5);
    i0.ɵɵlistener("dateSelect", function DateTimeEditFieldComponent_ng_template_4_Template_ngb_datepicker_dateSelect_2_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.onDateChange($event)); });
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(3, "div", 6)(4, "ngb-timepicker", 7);
    i0.ɵɵlistener("ngModelChange", function DateTimeEditFieldComponent_ng_template_4_Template_ngb_timepicker_ngModelChange_4_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.onTimeChange($event)); });
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", ctx_r1.dateTimeModel.date)("startDate", ctx_r1.dateTimeModel.date);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", ctx_r1.dateTimeModel.time)("seconds", ctx_r1.dateTimeModel.displaySeconds)("hourStep", ctx_r1.dateTimeModel.hourStep)("minuteStep", ctx_r1.dateTimeModel.minuteStep)("secondStep", ctx_r1.dateTimeModel.secondStep);
} }
class DateTimeEditFieldComponent extends BaseDateTimeComponent {
    constructor(formatter, typeFormatter, calendar, config, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.calendar = calendar;
        this.config = config;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.dateTimeModel = new DateTimeModel();
        config.autoClose = "outside";
        config.placement = this.getPlacement();
    }
    ngOnInit() {
        // Note: handle NgbDatePicker default validation
        // Note: convert empty form value to null for the ngb date validator to pass it
        if (isVoid(this.field.value) || isEmptyString(this.field.value)) {
            this.dateTimeModel.date = this.calendar.getToday();
            this.dateTimeModel.time = { hour: 0, minute: 0, second: 0 };
            this.field.formControl.setValue(null);
        }
        else {
            this.dateTimeModel = DateTimeModel.internalToDateTimeStruct(this.formatter, this.field.value);
            if (this.dateTimeModel === null) {
                this.field.formControl.setValue(null);
                return;
            }
            this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter, { toFormat: this.getDateTimeFormat() }));
        }
        // enable seconds in timepicker
        if (this.formatter.getTimeFormat().includes('ss')) {
            this.dateTimeModel.displaySeconds = true;
        }
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    setFormValues(dateTimeString) {
        this.field.formControl.setValue(dateTimeString);
    }
    onDateChange(date) {
        this.dateTimeModel.date = date;
        this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter, { toFormat: this.getDateTimeFormat() }));
        this.field.formControl.markAsDirty();
    }
    onTimeChange(time) {
        this.dateTimeModel.time = time;
        this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter, { toFormat: this.getDateTimeFormat() }));
        this.field.formControl.markAsDirty();
    }
    onInputChange($event) {
        const dateTimeModel = DateTimeModel.toDateTimeStruct(this.formatter, $event.target.value);
        if (!dateTimeModel) {
            return;
        }
        this.dateTimeModel = dateTimeModel;
    }
    getOpenButton() {
        return {
            klass: 'btn btn-sm btn-outline-secondary m-0 border-0',
            icon: 'calendar'
        };
    }
    getPlacement() {
        return ['bottom-right', 'top-right', 'bottom-left', 'top-left'];
    }
    static { this.ɵfac = function DateTimeEditFieldComponent_Factory(t) { return new (t || DateTimeEditFieldComponent)(i0.ɵɵdirectiveInject(DatetimeFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(i3$1.NgbCalendar), i0.ɵɵdirectiveInject(i3$1.NgbPopoverConfig), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateTimeEditFieldComponent, selectors: [["scrm-datetime-edit"]], viewQuery: function DateTimeEditFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(NgbPopover, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.popover = _t.first);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 8, consts: [[1, "input-group", "mr-2"], [3, "ngClass", "placeholder", "formControl", "ngbPopover", "change"], [1, "input-group-append"], [3, "config", "ngbPopover"], ["calendarContent", ""], ["name", "datepicker", 3, "ngModel", "startDate", "dateSelect"], [1, "d-flex", "justify-content-center", "mt-auto"], ["name", "timepicker", 3, "ngModel", "seconds", "hourStep", "minuteStep", "secondStep", "ngModelChange"]], template: function DateTimeEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "input", 1);
            i0.ɵɵlistener("change", function DateTimeEditFieldComponent_Template_input_change_1_listener($event) { return ctx.onInputChange($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(2, "div", 2);
            i0.ɵɵelement(3, "scrm-button", 3);
            i0.ɵɵelementEnd()();
            i0.ɵɵtemplate(4, DateTimeEditFieldComponent_ng_template_4_Template, 5, 7, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(5);
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("ngClass", ctx.klass)("placeholder", ctx.getDateTimeFormat().toLowerCase())("formControl", ctx.field.formControl)("ngbPopover", _r0);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("config", ctx.getOpenButton())("ngbPopover", _r0);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgModel, i3$1.NgbDatepicker, i3$1.NgbTimepicker, ButtonComponent, i5$1.FormControlDirective, i3$1.NgbPopover], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-datetime-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"input-group mr-2\">\n\n    <input\n        [ngClass]=\"klass\"\n        [placeholder]=\"getDateTimeFormat().toLowerCase()\"\n        [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n        [formControl]=\"field.formControl\"\n        (change)=\"onInputChange($event)\"\n        [ngbPopover]=\"calendarContent\"\n    >\n\n    <div class=\"input-group-append\">\n        <scrm-button [config]=\"getOpenButton()\" [ngbPopover]=\"calendarContent\">\n        </scrm-button>\n    </div>\n</div>\n\n<ng-template #calendarContent>\n    <div>\n        <div>\n            <ngb-datepicker name=\"datepicker\"\n                            [ngModel]=\"dateTimeModel.date\"\n                            (dateSelect)=\"onDateChange($event)\" [startDate]=\"dateTimeModel.date\"></ngb-datepicker>\n        </div>\n\n        <div class=\"d-flex justify-content-center mt-auto\">\n            <ngb-timepicker name=\"timepicker\"\n                            [ngModel]=\"dateTimeModel.time\" (ngModelChange)=\"onTimeChange($event)\"\n                            [seconds]=\"dateTimeModel.displaySeconds\" [hourStep]=\"dateTimeModel.hourStep\"\n                            [minuteStep]=\"dateTimeModel.minuteStep\"\n                            [secondStep]=\"dateTimeModel.secondStep\">\n            </ngb-timepicker>\n        </div>\n    </div>\n</ng-template>\n" }]
    }], function () { return [{ type: DatetimeFormatter }, { type: DataTypeFormatter }, { type: i3$1.NgbCalendar }, { type: i3$1.NgbPopoverConfig }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { popover: [{
            type: ViewChild,
            args: [NgbPopover, { static: true }]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateTimeEditFieldModule {
    static { this.ɵfac = function DateTimeEditFieldModule_Factory(t) { return new (t || DateTimeEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateTimeEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            NgbDatepickerModule,
            NgbTimepickerModule,
            ImageModule,
            ButtonModule,
            ReactiveFormsModule,
            NgbModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateTimeEditFieldComponent],
                exports: [DateTimeEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    NgbDatepickerModule,
                    NgbTimepickerModule,
                    ImageModule,
                    ButtonModule,
                    ReactiveFormsModule,
                    NgbModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateTimeEditFieldModule, { declarations: [DateTimeEditFieldComponent], imports: [CommonModule,
        FormsModule,
        NgbDatepickerModule,
        NgbTimepickerModule,
        ImageModule,
        ButtonModule,
        ReactiveFormsModule,
        NgbModule], exports: [DateTimeEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateParserFormatter extends NgbDateParserFormatter {
    constructor(formatter) {
        super();
        this.formatter = formatter;
    }
    getUserFormat() {
        return this.userFormat;
    }
    setUserFormat(format) {
        this.userFormat = format;
    }
    parse(value) {
        if (!value) {
            return null;
        }
        const options = { fromFormat: 'yyyy-M-d' };
        if (this.userFormat) {
            options.toFormat = this.userFormat;
        }
        return this.formatter.dateFormatToStruct(value, options.toFormat || this.formatter.getUserFormat());
    }
    format(date) {
        if (!date) {
            return null;
        }
        const dateString = [date.year, date.month, date.day].join('-');
        const options = { fromFormat: 'yyyy-M-d' };
        if (this.userFormat) {
            options.toFormat = this.userFormat;
        }
        return this.formatter.toUserFormat(dateString, options);
    }
    static { this.ɵfac = function DateParserFormatter_Factory(t) { return new (t || DateParserFormatter)(i0.ɵɵinject(DateFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateParserFormatter, factory: DateParserFormatter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateParserFormatter, [{
        type: Injectable
    }], function () { return [{ type: DateFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateAdapter extends NgbDateAdapter {
    constructor(formatter) {
        super();
        this.formatter = formatter;
    }
    getUserFormat() {
        return this.userFormat;
    }
    setUserFormat(format) {
        this.userFormat = format;
    }
    fromModel(value) {
        if (!value) {
            return null;
        }
        return this.formatter.dateFormatToStruct(value, this.userFormat || '');
    }
    toModel(date) {
        if (!date) {
            return null;
        }
        const dateString = [date.year, date.month, date.day].join('-');
        const options = { fromFormat: 'yyyy-M-d' };
        if (this.userFormat) {
            options.toFormat = this.userFormat;
        }
        return this.formatter.toUserFormat(dateString, options);
    }
    static { this.ɵfac = function DateAdapter_Factory(t) { return new (t || DateAdapter)(i0.ɵɵinject(DateFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateAdapter, factory: DateAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateAdapter, [{
        type: Injectable
    }], function () { return [{ type: DateFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateEditFieldComponent extends BaseDateComponent {
    constructor(formatter, dateAdapter, dateParserFormatter, typeFormatter, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.dateAdapter = dateAdapter;
        this.dateParserFormatter = dateParserFormatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        // Note: handle NgbDatePicker default validation
        // Note: convert empty form value to null for the ngb date validator to pass it
        if (isVoid(this.field.value) || isEmptyString(this.field.value)) {
            this.field.formControl.setValue(null);
        }
        else {
            this.field.formControl.setValue(this.formatter.toUserFormat(this.field.value, { toFormat: this.getDateFormat() }));
        }
        const adapter = this.dateAdapter;
        adapter.setUserFormat(this.getDateFormat());
        const parserFormatter = this.dateParserFormatter;
        parserFormatter.setUserFormat(this.getDateFormat());
        this.dateModel = this.formatter.dateFormatToStruct(this.field.value, this.formatter.getInternalFormat());
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    setModel(value) {
        this.field.value = this.formatter.toInternalFormat(value, { fromFormat: this.getDateFormat() });
        this.dateModel = this.formatter.dateFormatToStruct(value, this.getDateFormat());
    }
    getOpenButton(datepicker) {
        return {
            klass: 'btn btn-sm btn-outline-secondary m-0 border-0',
            // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
            onClick: () => {
                datepicker.toggle();
                datepicker.navigateTo(this.dateModel);
            },
            icon: 'calendar'
        };
    }
    openDatePicker(datepicker) {
        datepicker.toggle(); // Open the datepicker popup
        datepicker.navigateTo(this.dateModel);
    }
    getPlacement() {
        return ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
    }
    static { this.ɵfac = function DateEditFieldComponent_Factory(t) { return new (t || DateEditFieldComponent)(i0.ɵɵdirectiveInject(DateFormatter), i0.ɵɵdirectiveInject(i3$1.NgbDateAdapter), i0.ɵɵdirectiveInject(i3$1.NgbDateParserFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateEditFieldComponent, selectors: [["scrm-date-edit"]], features: [i0.ɵɵProvidersFeature([
                { provide: NgbDateAdapter, useClass: DateAdapter },
                { provide: NgbDateParserFormatter, useClass: DateParserFormatter }
            ]), i0.ɵɵInheritDefinitionFeature], decls: 5, vars: 8, consts: [[1, "field-datetime-edit", "input-group"], ["ngbDatepicker", "", 3, "ngClass", "placement", "placeholder", "formControl", "startDate", "ngModelChange", "click"], ["datepicker", "ngbDatepicker"], [1, "input-group-append", "align-items-end"], [3, "config"]], template: function DateEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            const _r1 = i0.ɵɵgetCurrentView();
            i0.ɵɵelementStart(0, "div", 0)(1, "input", 1, 2);
            i0.ɵɵlistener("ngModelChange", function DateEditFieldComponent_Template_input_ngModelChange_1_listener($event) { return ctx.setModel($event); })("click", function DateEditFieldComponent_Template_input_click_1_listener() { i0.ɵɵrestoreView(_r1); const _r0 = i0.ɵɵreference(2); return i0.ɵɵresetView(ctx.openDatePicker(_r0)); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(3, "span", 3);
            i0.ɵɵelement(4, "scrm-button", 4);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(2);
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("ngClass", ctx.klass)("placement", ctx.getPlacement())("placeholder", ctx.getDateFormat().toLowerCase())("formControl", ctx.field.formControl)("startDate", ctx.dateModel);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("config", ctx.getOpenButton(_r0));
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i3$1.NgbInputDatepicker, ButtonComponent, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-date-edit', providers: [
                    { provide: NgbDateAdapter, useClass: DateAdapter },
                    { provide: NgbDateParserFormatter, useClass: DateParserFormatter }
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"field-datetime-edit input-group\">\n    <input ngbDatepicker\n           [ngClass]=\"klass\"\n           [placement]=\"getPlacement()\"\n           [placeholder]=\"getDateFormat().toLowerCase()\"\n           [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n           [formControl]=\"field.formControl\"\n           [startDate]=\"dateModel\"\n           (ngModelChange)=\"setModel($event)\"\n           (click)=\"openDatePicker(datepicker)\"\n           #datepicker=\"ngbDatepicker\">\n    <span class=\"input-group-append align-items-end\">\n        <scrm-button [config]=\"getOpenButton(datepicker)\">\n        </scrm-button>\n    </span>\n</div>\n" }]
    }], function () { return [{ type: DateFormatter }, { type: i3$1.NgbDateAdapter }, { type: i3$1.NgbDateParserFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateFilterFieldComponent extends DateEditFieldComponent {
    constructor(formatter, dateAdapter, dateParserFormatter, typeFormatter, logic, logicDisplay) {
        super(formatter, dateAdapter, dateParserFormatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.dateAdapter = dateAdapter;
        this.dateParserFormatter = dateParserFormatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        let current = null;
        if (this.field.criteria.values && this.field.criteria.values.length > 0) {
            current = this.field.criteria.values[0];
        }
        if (!isVoid(current) && !isEmptyString(current)) {
            current = current.trim();
        }
        this.field.value = current ?? '';
        super.ngOnInit();
    }
    setFieldValue(newValue) {
        super.setFieldValue(newValue);
        this.field.criteria.operator = '=';
        this.field.criteria.values = [newValue];
    }
    static { this.ɵfac = function DateFilterFieldComponent_Factory(t) { return new (t || DateFilterFieldComponent)(i0.ɵɵdirectiveInject(DateFormatter), i0.ɵɵdirectiveInject(i3$1.NgbDateAdapter), i0.ɵɵdirectiveInject(i3$1.NgbDateParserFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateFilterFieldComponent, selectors: [["scrm-date-filter"]], features: [i0.ɵɵProvidersFeature([
                { provide: NgbDateAdapter, useClass: DateAdapter },
                { provide: NgbDateParserFormatter, useClass: DateParserFormatter }
            ]), i0.ɵɵInheritDefinitionFeature], decls: 5, vars: 8, consts: [[1, "input-group"], ["ngbDatepicker", "", 3, "ngClass", "placement", "placeholder", "formControl", "startDate", "ngModelChange"], ["datepicker", "ngbDatepicker"], [1, "input-group-append", "align-items-end"], [3, "config"]], template: function DateFilterFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "input", 1, 2);
            i0.ɵɵlistener("ngModelChange", function DateFilterFieldComponent_Template_input_ngModelChange_1_listener($event) { return ctx.setModel($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(3, "span", 3);
            i0.ɵɵelement(4, "scrm-button", 4);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(2);
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("ngClass", ctx.klass)("placement", ctx.getPlacement())("placeholder", ctx.getDateFormat().toLowerCase())("formControl", ctx.field.formControl)("startDate", ctx.dateModel);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("config", ctx.getOpenButton(_r0));
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i3$1.NgbInputDatepicker, ButtonComponent, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateFilterFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-date-filter', providers: [
                    { provide: NgbDateAdapter, useClass: DateAdapter },
                    { provide: NgbDateParserFormatter, useClass: DateParserFormatter }
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"input-group\">\n    <input ngbDatepicker\n           [ngClass]=\"klass\"\n           [placement]=\"getPlacement()\"\n           [placeholder]=\"getDateFormat().toLowerCase()\"\n           [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n           [formControl]=\"field.formControl\"\n           [startDate]=\"dateModel\"\n           (ngModelChange)=\"setModel($event)\"\n           #datepicker=\"ngbDatepicker\">\n    <span class=\"input-group-append align-items-end\">\n        <scrm-button [config]=\"getOpenButton(datepicker)\">\n        </scrm-button>\n    </span>\n</div>\n" }]
    }], function () { return [{ type: DateFormatter }, { type: i3$1.NgbDateAdapter }, { type: i3$1.NgbDateParserFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DateTimeDetailFieldComponent_ng_container_0_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "date");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind3(2, 1, ctx_r2.toDateTime(ctx_r2.field.value), ctx_r2.getDateTimeFormat(), ctx_r2.getUserTimeZone()), " ");
} }
function DateTimeDetailFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DateTimeDetailFieldComponent_ng_container_0_span_1_Template, 3, 5, "span", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.field.value);
} }
class DateTimeDetailFieldComponent extends BaseDateTimeComponent {
    constructor(formatter, typeFormatter, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    getUserTimeZone() {
        return this.formatter.userTimeZone();
    }
    toDateTime(dateString) {
        return this.formatter.toDateTime(dateString, this.formatter.getInternalFormat(), {
            zone: 'GMT'
        }).toJSDate();
    }
    static { this.ɵfac = function DateTimeDetailFieldComponent_Factory(t) { return new (t || DateTimeDetailFieldComponent)(i0.ɵɵdirectiveInject(DatetimeFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateTimeDetailFieldComponent, selectors: [["scrm-datetime-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[4, "ngIf"]], template: function DateTimeDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, DateTimeDetailFieldComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe, i2.DatePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-datetime-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <span *ngIf=\"field.value\">\n    {{toDateTime(field.value) | date:getDateTimeFormat():getUserTimeZone()}}\n    </span>\n</ng-container>\n" }]
    }], function () { return [{ type: DatetimeFormatter }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateTimeDetailFieldModule {
    static { this.ɵfac = function DateTimeDetailFieldModule_Factory(t) { return new (t || DateTimeDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateTimeDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateTimeDetailFieldComponent],
                exports: [DateTimeDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateTimeDetailFieldModule, { declarations: [DateTimeDetailFieldComponent], imports: [CommonModule], exports: [DateTimeDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DateTimeFilterFieldComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div")(1, "div")(2, "ngb-datepicker", 5);
    i0.ɵɵlistener("dateSelect", function DateTimeFilterFieldComponent_ng_template_4_Template_ngb_datepicker_dateSelect_2_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.onDateChange($event)); });
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(3, "div", 6)(4, "ngb-timepicker", 7);
    i0.ɵɵlistener("ngModelChange", function DateTimeFilterFieldComponent_ng_template_4_Template_ngb_timepicker_ngModelChange_4_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.onTimeChange($event)); });
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", ctx_r1.dateTimeModel.date)("startDate", ctx_r1.dateTimeModel.date);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", ctx_r1.dateTimeModel.time)("seconds", ctx_r1.dateTimeModel.displaySeconds)("hourStep", ctx_r1.dateTimeModel.hourStep)("minuteStep", ctx_r1.dateTimeModel.minuteStep)("secondStep", ctx_r1.dateTimeModel.secondStep);
} }
class DateTimeFilterFieldComponent extends BaseDateTimeComponent {
    constructor(formatter, typeFormatter, calendar, config, logic, logicDisplay) {
        super(formatter, typeFormatter, logic, logicDisplay);
        this.formatter = formatter;
        this.typeFormatter = typeFormatter;
        this.calendar = calendar;
        this.config = config;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.dateTimeModel = new DateTimeModel();
        config.autoClose = "outside";
        config.placement = this.getPlacement();
    }
    ngOnInit() {
        super.ngOnInit();
        const values = (this.field && this.field.criteria && this.field.criteria.values) || [];
        let criteria = '';
        if (values.length > 0) {
            criteria = this.field.criteria.values[0];
        }
        // Note: handle NgbDatePicker default validation
        // Note: convert empty form value to null for the ngb date validator to pass it
        if (isEmptyString(criteria)) {
            this.dateTimeModel.date = this.calendar.getToday();
            this.dateTimeModel.time = { hour: 0, minute: 0, second: 0 };
            this.field.formControl.setValue(null);
        }
        else {
            this.dateTimeModel = DateTimeModel.internalToDateTimeStruct(this.formatter, criteria);
            if (this.dateTimeModel === null) {
                this.field.formControl.setValue(null);
                return;
            }
            this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter));
        }
        // enable seconds in timepicker
        if (this.formatter.getTimeFormat().includes('ss')) {
            this.dateTimeModel.displaySeconds = true;
        }
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    setFormValues(dateTimeString) {
        this.field.formControl.setValue(dateTimeString);
        this.field.formControl.markAsDirty();
    }
    setFieldValue(newValue) {
        this.field.value = newValue;
        this.field.criteria.operator = '=';
        this.field.criteria.values = [newValue];
    }
    onDateChange(date) {
        this.dateTimeModel.date = date;
        this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter));
    }
    onTimeChange(time) {
        this.dateTimeModel.time = time;
        this.setFormValues(this.dateTimeModel.toUserFormat(this.formatter));
    }
    onInputChange($event) {
        const dateTimeModel = DateTimeModel.toDateTimeStruct(this.formatter, $event.target.value);
        if (!dateTimeModel) {
            return;
        }
        this.dateTimeModel = dateTimeModel;
    }
    getOpenButton() {
        return {
            klass: 'btn btn-sm btn-outline-secondary m-0 border-0',
            icon: 'calendar'
        };
    }
    getPlacement() {
        return ['bottom-right', 'top-right', 'bottom-left', 'top-left'];
    }
    static { this.ɵfac = function DateTimeFilterFieldComponent_Factory(t) { return new (t || DateTimeFilterFieldComponent)(i0.ɵɵdirectiveInject(DatetimeFormatter), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(i3$1.NgbCalendar), i0.ɵɵdirectiveInject(i3$1.NgbPopoverConfig), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateTimeFilterFieldComponent, selectors: [["scrm-datetime-filter"]], viewQuery: function DateTimeFilterFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(NgbPopover, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.popover = _t.first);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 7, consts: [[1, "input-group", "mr-2"], [3, "ngClass", "placeholder", "formControl", "change"], [1, "input-group-append"], [3, "config", "ngbPopover"], ["calendarContent", ""], ["name", "datepicker", 3, "ngModel", "startDate", "dateSelect"], [1, "d-flex", "justify-content-center", "mt-auto"], ["name", "timepicker", 3, "ngModel", "seconds", "hourStep", "minuteStep", "secondStep", "ngModelChange"]], template: function DateTimeFilterFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "input", 1);
            i0.ɵɵlistener("change", function DateTimeFilterFieldComponent_Template_input_change_1_listener($event) { return ctx.onInputChange($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(2, "div", 2);
            i0.ɵɵelement(3, "scrm-button", 3);
            i0.ɵɵelementEnd()();
            i0.ɵɵtemplate(4, DateTimeFilterFieldComponent_ng_template_4_Template, 5, 7, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(5);
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("ngClass", ctx.klass)("placeholder", ctx.getDateTimeFormat().toLowerCase())("formControl", ctx.field.formControl);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("config", ctx.getOpenButton())("ngbPopover", _r0);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgModel, i3$1.NgbDatepicker, i3$1.NgbTimepicker, ButtonComponent, i5$1.FormControlDirective, i3$1.NgbPopover], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeFilterFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-datetime-filter', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"input-group mr-2\">\n\n    <input\n        [ngClass]=\"klass\"\n        [placeholder]=\"getDateTimeFormat().toLowerCase()\"\n        [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n        [formControl]=\"field.formControl\"\n        (change)=\"onInputChange($event)\"\n    >\n\n    <div class=\"input-group-append\">\n        <scrm-button [config]=\"getOpenButton()\" [ngbPopover]=\"calendarContent\">\n        </scrm-button>\n    </div>\n</div>\n\n<ng-template #calendarContent>\n    <div>\n        <div>\n            <ngb-datepicker name=\"datepicker\"\n                            [ngModel]=\"dateTimeModel.date\"\n                            (dateSelect)=\"onDateChange($event)\" [startDate]=\"dateTimeModel.date\"></ngb-datepicker>\n        </div>\n\n        <div class=\"d-flex justify-content-center mt-auto\">\n            <ngb-timepicker name=\"timepicker\"\n                            [ngModel]=\"dateTimeModel.time\" (ngModelChange)=\"onTimeChange($event)\"\n                            [seconds]=\"dateTimeModel.displaySeconds\" [hourStep]=\"dateTimeModel.hourStep\"\n                            [minuteStep]=\"dateTimeModel.minuteStep\"\n                            [secondStep]=\"dateTimeModel.secondStep\">\n            </ngb-timepicker>\n        </div>\n    </div>\n</ng-template>\n" }]
    }], function () { return [{ type: DatetimeFormatter }, { type: DataTypeFormatter }, { type: i3$1.NgbCalendar }, { type: i3$1.NgbPopoverConfig }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { popover: [{
            type: ViewChild,
            args: [NgbPopover, { static: true }]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateTimeFilterFieldModule {
    static { this.ɵfac = function DateTimeFilterFieldModule_Factory(t) { return new (t || DateTimeFilterFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateTimeFilterFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            NgbDatepickerModule,
            NgbTimepickerModule,
            ImageModule,
            ButtonModule,
            ReactiveFormsModule,
            NgbModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeFilterFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateTimeFilterFieldComponent],
                exports: [DateTimeFilterFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    NgbDatepickerModule,
                    NgbTimepickerModule,
                    ImageModule,
                    ButtonModule,
                    ReactiveFormsModule,
                    NgbModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateTimeFilterFieldModule, { declarations: [DateTimeFilterFieldComponent], imports: [CommonModule,
        FormsModule,
        NgbDatepickerModule,
        NgbTimepickerModule,
        ImageModule,
        ButtonModule,
        ReactiveFormsModule,
        NgbModule], exports: [DateTimeFilterFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function MultiEnumDetailFieldComponent_li_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const selected_r1 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(selected_r1.label);
} }
class MultiEnumDetailFieldComponent extends BaseMultiEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function MultiEnumDetailFieldComponent_Factory(t) { return new (t || MultiEnumDetailFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MultiEnumDetailFieldComponent, selectors: [["scrm-multienum-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[4, "ngFor", "ngForOf"]], template: function MultiEnumDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "ul");
            i0.ɵɵtemplate(1, MultiEnumDetailFieldComponent_li_1_Template, 2, 1, "li", 0);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngForOf", ctx.selectedValues);
        } }, dependencies: [i2.NgForOf], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-multienum-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ul>\n    <li *ngFor=\"let selected of selectedValues;\">{{selected.label}}</li>\n</ul>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$F = ["tag"];
class EnumEditFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        this.checkAndInitAsDynamicEnum();
        super.ngOnInit();
    }
    onAdd(item) {
        if (item && item.value) {
            this.field.value = item.value;
            this.field.formControl.setValue(item.value);
            this.field.formControl.markAsDirty();
            return;
        }
        this.field.value = '';
        this.field.formControl.setValue('');
        this.field.formControl.markAsDirty();
        this.selectedValues = [];
        return;
    }
    onRemove() {
        this.field.value = '';
        this.field.formControl.setValue('');
        this.field.formControl.markAsDirty();
        setTimeout(() => {
            this.tag.focus(true, true);
            this.tag.dropdown.show();
        }, 200);
    }
    getPlaceholderLabel() {
        return this.languages.getAppString('LBL_SELECT_ITEM') || '';
    }
    selectFirstElement() {
        const filteredElements = this.tag.dropdown.items;
        if (filteredElements.length !== 0) {
            const firstElement = filteredElements[0];
            this.selectedValues.push(firstElement);
            this.onAdd(firstElement);
            this.tag.dropdown.hide();
        }
    }
    static { this.ɵfac = function EnumEditFieldComponent_Factory(t) { return new (t || EnumEditFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EnumEditFieldComponent, selectors: [["scrm-enum-edit"]], viewQuery: function EnumEditFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$F, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tag = _t.first);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 15, consts: [["maxItems", "1", 3, "ngModel", "onlyFromAutocomplete", "clearOnBlur", "displayBy", "identifyBy", "placeholder", "secondaryPlaceholder", "inputClass", "ngModelChange", "onAdd", "onRemove", "keyup.enter"], ["tag", ""], [3, "displayBy", "identifyBy", "showDropdownIfEmpty", "keepOpen", "autocompleteItems"]], template: function EnumEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "tag-input", 0, 1);
            i0.ɵɵlistener("ngModelChange", function EnumEditFieldComponent_Template_tag_input_ngModelChange_0_listener($event) { return ctx.selectedValues = $event; })("onAdd", function EnumEditFieldComponent_Template_tag_input_onAdd_0_listener($event) { return ctx.onAdd($event); })("onRemove", function EnumEditFieldComponent_Template_tag_input_onRemove_0_listener() { return ctx.onRemove(); })("keyup.enter", function EnumEditFieldComponent_Template_tag_input_keyup_enter_0_listener() { return ctx.selectFirstElement(); });
            i0.ɵɵelement(2, "tag-input-dropdown", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMap(ctx.getInvalidClass());
            i0.ɵɵproperty("ngModel", ctx.selectedValues)("onlyFromAutocomplete", true)("clearOnBlur", true)("displayBy", "label")("identifyBy", "value")("placeholder", ctx.getPlaceholderLabel())("secondaryPlaceholder", ctx.getPlaceholderLabel())("inputClass", ctx.getInvalidClass());
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("displayBy", "label")("identifyBy", "value")("showDropdownIfEmpty", true)("keepOpen", false)("autocompleteItems", ctx.options);
        } }, dependencies: [i5$2.TagInputComponent, i5$2.TagInputDropdown, i5$1.NgControlStatus, i5$1.NgModel], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EnumEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-enum-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<tag-input [(ngModel)]=\"selectedValues\"\n           [onlyFromAutocomplete]=\"true\"\n           [clearOnBlur]=\"true\"\n           [displayBy]=\"'label'\"\n           [identifyBy]=\"'value'\"\n           [placeholder]=\"getPlaceholderLabel()\"\n           [secondaryPlaceholder]=\"getPlaceholderLabel()\"\n           [class]=\"getInvalidClass()\"\n           [inputClass]=\"getInvalidClass()\"\n           maxItems=\"1\"\n           #tag\n           (onAdd)=\"onAdd($event)\"\n           (onRemove)=\"onRemove()\"\n           (keyup.enter)=\"selectFirstElement()\">\n    <tag-input-dropdown [displayBy]=\"'label'\"\n                        [identifyBy]=\"'value'\"\n                        [showDropdownIfEmpty]=\"true\"\n                        [keepOpen]=\"false\"\n                        [autocompleteItems]=\"this.options\">\n    </tag-input-dropdown>\n</tag-input>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { tag: [{
            type: ViewChild,
            args: ['tag']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseBooleanComponent extends BaseFieldComponent {
    get checked() {
        return isTrue(this.field.value);
    }
    toggle() {
        let newValue = 'true';
        if (this.checked) {
            newValue = 'false';
        }
        this.field.value = newValue;
        this.field.formControl.setValue(newValue);
        this.field.formControl.markAsDirty();
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵBaseBooleanComponent_BaseFactory; return function BaseBooleanComponent_Factory(t) { return (ɵBaseBooleanComponent_BaseFactory || (ɵBaseBooleanComponent_BaseFactory = i0.ɵɵgetInheritedFactory(BaseBooleanComponent)))(t || BaseBooleanComponent); }; }(); }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseBooleanComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseBooleanComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseBooleanComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BooleanDetailFieldComponent extends BaseBooleanComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function BooleanDetailFieldComponent_Factory(t) { return new (t || BooleanDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BooleanDetailFieldComponent, selectors: [["scrm-boolean-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 1, consts: [[1, "checkbox-container"], ["type", "checkbox", "disabled", "", "readonly", "", "aria-hidden", "true", 3, "checked"], [1, "checkmark"]], template: function BooleanDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "label", 0);
            i0.ɵɵelement(1, "input", 1)(2, "span", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("checked", ctx.checked);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BooleanDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-boolean-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<label class=\"checkbox-container\">\n    <input type=\"checkbox\"\n           [checked]=\"checked\"\n           disabled\n           readonly\n           aria-hidden=\"true\">\n    <span class=\"checkmark\"></span>\n</label>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModuleNameMapper {
    constructor(systemConfig) {
        this.systemConfig = systemConfig;
    }
    /**
     * Public Api
     */
    /**
     * Map the legacy name to frontend
     *
     * @param {string} module the module name
     * @returns {string} frontend name
     */
    toFrontend(module) {
        const map = this.getLegacyToFrontendMap();
        if (!map || !map[module]) {
            return module;
        }
        return map[module];
    }
    /**
     * Map the frontend name to legacy
     *
     * @param {string} module the module name
     * @returns {string} frontend name
     */
    toLegacy(module) {
        const map = this.getFrontendToLegacyMap();
        if (!map[module]) {
            return module;
        }
        return map[module];
    }
    /**
     * Check if module is valid
     *
     * @param {string} module the module name
     * @returns {boolean} is valid
     */
    isValid(module) {
        const map = this.getFrontendToLegacyMap();
        let valid = false;
        if (map[module]) {
            valid = true;
        }
        return valid;
    }
    /**
     * Internal API
     */
    /**
     * Get the legacy to frontend map
     *
     * @returns {{}} map
     */
    getLegacyToFrontendMap() {
        return this.systemConfig.getConfigValue('module_name_map');
    }
    /**
     * Get the frontend to legacy map
     *
     * @returns {{}} map
     */
    getFrontendToLegacyMap() {
        const map = this.systemConfig.getConfigValue('module_name_map');
        const invertedMap = {};
        Object.keys(map).forEach((legacyName) => {
            const frontendName = map[legacyName];
            invertedMap[frontendName] = legacyName;
        });
        return invertedMap;
    }
    static { this.ɵfac = function ModuleNameMapper_Factory(t) { return new (t || ModuleNameMapper)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ModuleNameMapper, factory: ModuleNameMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModuleNameMapper, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ActionNameMapper {
    constructor(systemConfig) {
        this.systemConfig = systemConfig;
    }
    /**
     * Public Api
     */
    /**
     * Map the legacy name to frontend
     *
     * @param {string} action the action name
     * @returns {string} frontend name
     */
    toFrontend(action) {
        const map = this.getLegacyToFrontendMap();
        if (!map[action]) {
            return action;
        }
        return map[action];
    }
    /**
     * Map the frontend name to legacy
     *
     * @param {string} action the action name
     * @returns {string} frontend name
     */
    toLegacy(action) {
        const map = this.getFrontendToLegacyMap();
        if (!map[action]) {
            return action;
        }
        return map[action];
    }
    /**
     * Check if action is valid
     *
     * @param {string} action the action name
     * @returns {boolean} is valid
     */
    isValid(action) {
        const map = this.getFrontendToLegacyMap();
        let valid = false;
        if (map[action]) {
            valid = true;
        }
        return valid;
    }
    /**
     * Internal API
     */
    /**
     * Get the legacy to frontend map
     *
     * @returns {{}} legacy to frontend map
     */
    getLegacyToFrontendMap() {
        return this.systemConfig.getConfigValue('action_name_map');
    }
    /**
     * Get the frontend to legacy map
     *
     * @returns {{}} frontend to legacy map
     */
    getFrontendToLegacyMap() {
        const map = this.systemConfig.getConfigValue('action_name_map');
        const invertedMap = {};
        Object.keys(map).forEach((legacyName) => {
            const frontendName = map[legacyName];
            invertedMap[frontendName] = legacyName;
        });
        return invertedMap;
    }
    static { this.ɵfac = function ActionNameMapper_Factory(t) { return new (t || ActionNameMapper)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ActionNameMapper, factory: ActionNameMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionNameMapper, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const ROUTE_PREFIX$1 = './#';
class ModuleNavigation {
    constructor(router, moduleNameMapper, actionNameMapper) {
        this.router = router;
        this.moduleNameMapper = moduleNameMapper;
        this.actionNameMapper = actionNameMapper;
    }
    /**
     * Public Api
     */
    /**
     * Get module info
     *
     * @param {string} module name
     * @param {object} navigation info
     * @returns {object} module info
     */
    getModuleInfo(module, navigation) {
        if (!navigation || !navigation.modules) {
            return null;
        }
        return navigation.modules[module];
    }
    /**
     * Get module label
     *
     * @param {object} module info
     * @param {object} appListStrings map
     * @returns {string} the module label
     */
    getModuleLabel(module, appListStrings) {
        if (!appListStrings || !appListStrings.moduleList || !module) {
            return '';
        }
        const labelKey = (module && module.labelKey) || '';
        return appListStrings.moduleList[labelKey] || labelKey;
    }
    /**
     * Get module route
     *
     * @param {object} module NavbarModule
     * @returns {object} NavigationRoute
     */
    getModuleRoute(module) {
        let url = (module && module.defaultRoute) || '';
        let route = null;
        const params = null;
        if (url.startsWith(ROUTE_PREFIX$1)) {
            route = url.replace(ROUTE_PREFIX$1, '');
            url = null;
        }
        return { route, url, params };
    }
    /**
     * Navigate using action information
     *
     * @param {object} item ModuleAction
     * @returns {object} Promise<boolean>
     */
    navigate(item) {
        const route = this.getActionRoute(item);
        return this.router.navigate([route.route], {
            queryParams: route.params
        });
    }
    /**
     * Navigate using menu item information
     *
     * @param {object} item MenuItem
     */
    navigateUsingMenuItem(item) {
        if (item.link.route) {
            this.router.navigate([item.link.route ?? ''], {
                queryParams: item.link.params ?? {}
            }).then();
            return;
        }
        if (item.link.url) {
            this.router.navigateByUrl(item.link.url ?? '').then();
            return;
        }
    }
    /**
     * Get action route info
     *
     * @param {object} action ModuleAction
     * @returns {object} NavigationRoute
     */
    getActionRoute(action) {
        let url = action.url;
        let route = null;
        let params = {};
        let process = action?.process;
        if (url.startsWith(ROUTE_PREFIX$1)) {
            route = url.replace(ROUTE_PREFIX$1, '');
            url = null;
            if (action.params) {
                params = action.params;
            }
            else {
                const routeParts = route.split('?');
                route = routeParts[0];
                const queryParamsStr = routeParts[1];
                const queryParamsObj = {};
                if (queryParamsStr) {
                    queryParamsStr.split('&').forEach(param => {
                        const keyValue = param.split('=');
                        queryParamsObj[keyValue[0]] = keyValue[1];
                    });
                }
                params = queryParamsObj;
            }
        }
        return { route, url, params, process };
    }
    /**
     * Get label for module action item
     *
     * @param {string} module name
     * @param {object} item action
     * @param {object} languages map
     * @param {string} labelKey to use
     * @returns {string} label
     */
    getActionLabel(module, item, languages, labelKey = '') {
        if (!languages || !languages.modStrings || !item || !module) {
            return '';
        }
        let key = labelKey;
        if (!key) {
            key = item.labelKey;
        }
        let label = languages.modStrings[module] && languages.modStrings[module][key];
        if (!label) {
            label = languages.appStrings && languages.appStrings[key];
        }
        if (!label && item.module) {
            label = languages.modStrings[item.module] && languages.modStrings[item.module][key];
        }
        if (!label) {
            label = languages.modStrings.administration && languages.modStrings.administration[key];
        }
        return label || '';
    }
    /**
     * Get record router link route info
     *
     * @param {string} module name
     * @param {string} id fo the record
     * @returns {string} router link
     */
    getRecordRouterLink(module, id, isEdit) {
        if (isEdit) {
            return `/${module}/edit/${id}`;
        }
        return `/${module}/record/${id}`;
    }
    /**
     * Navigate back using return params
     * @param record
     * @param moduleName
     * @param params
     */
    navigateBack(record, moduleName, params) {
        let returnModule = this.getReturnModule(params);
        let returnAction = this.getReturnAction(params);
        const returnId = this.getReturnId(params);
        let route = '';
        if (returnModule) {
            route += '/' + returnModule;
        }
        if (returnAction) {
            route += '/' + returnAction;
        }
        if (returnId) {
            route += '/' + returnId;
        }
        if (returnModule === moduleName && returnAction === 'record') {
            const rid = !returnId ? record.id : returnId;
            route = '/' + moduleName + '/record/' + rid;
        }
        if (!route && record && record.id) {
            route = '/' + moduleName + '/record/' + record.id;
        }
        if (!route && record && record.id) {
            route = '/' + moduleName;
        }
        this.router.navigate([route]).then();
    }
    /**
     * Extract return id
     * @param params
     */
    getReturnId(params) {
        return params.return_id || '';
    }
    /**
     * Extract and map return action
     * @param params
     */
    getReturnAction(params) {
        let returnAction = '';
        if (params.return_action) {
            returnAction = this.actionNameMapper.toFrontend(params.return_action);
        }
        return returnAction;
    }
    /**
     * Extract and map return action
     * @param params
     */
    getReturnModule(params) {
        let returnModule = '';
        if (params.return_module) {
            returnModule = this.moduleNameMapper.toFrontend(params.return_module);
        }
        return returnModule;
    }
    static { this.ɵfac = function ModuleNavigation_Factory(t) { return new (t || ModuleNavigation)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(ActionNameMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ModuleNavigation, factory: ModuleNavigation.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModuleNavigation, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: i1$2.Router }, { type: ModuleNameMapper }, { type: ActionNameMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function EmailListFieldsComponent_a_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 3);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵpropertyInterpolate1("href", "mailto:", ctx_r0.field.value, "", i0.ɵɵsanitizeUrl);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r0.field.value);
} }
function EmailListFieldsComponent_a_2_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 4);
    i0.ɵɵlistener("click", function EmailListFieldsComponent_a_2_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.openEmail()); });
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r1.field.value);
} }
class EmailListFieldsComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay, preferences, navigation, moduleNameMapper, actionNameMapper, appState, modalService, router) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.preferences = preferences;
        this.navigation = navigation;
        this.moduleNameMapper = moduleNameMapper;
        this.actionNameMapper = actionNameMapper;
        this.appState = appState;
        this.modalService = modalService;
        this.router = router;
    }
    ngOnInit() {
        this.linkType = this.preferences.getUserPreference('email_link_type') || 'mailto';
    }
    openEmail() {
        const view = this.actionNameMapper.toLegacy(this.appState.getView());
        const module = this.moduleNameMapper.toLegacy(this.parent.module);
        const parent_id = this.parent.id;
        const parent_name = this.parent.attributes.name;
        const email = this.field.value;
        let return_id;
        if (view !== 'ListView' && view !== 'index') {
            return_id = parent_id;
        }
        this.router.navigate(['emails', 'compose'], {
            queryParams: {
                return_module: module,
                return_action: view,
                return_id,
                to_addrs_names: email,
                parent_type: module,
                parent_name,
                parent_id,
            }
        });
    }
    static { this.ɵfac = function EmailListFieldsComponent_Factory(t) { return new (t || EmailListFieldsComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(ActionNameMapper), i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(i3$1.NgbModal), i0.ɵɵdirectiveInject(i1$2.Router)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EmailListFieldsComponent, selectors: [["scrm-email-list"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 2, consts: [[1, "mailto-field"], [3, "href", 4, "ngIf"], ["class", "clickable field-link", 3, "click", 4, "ngIf"], [3, "href"], [1, "clickable", "field-link", 3, "click"]], template: function EmailListFieldsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, EmailListFieldsComponent_a_1_Template, 2, 2, "a", 1);
            i0.ɵɵtemplate(2, EmailListFieldsComponent_a_2_Template, 2, 1, "a", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.linkType === "mailto");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.linkType === "sugar");
        } }, dependencies: [i2.NgIf], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailListFieldsComponent, [{
        type: Component,
        args: [{ selector: 'scrm-email-list', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"mailto-field\">\n    <a *ngIf=\"linkType === 'mailto'\" href=\"mailto:{{ this.field.value }}\">{{ this.field.value }}</a>\n\n    <a *ngIf=\"linkType === 'sugar'\" class=\"clickable field-link\" (click)=\"openEmail()\">{{ this.field.value }}</a>\n</div>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: UserPreferenceStore }, { type: ModuleNavigation }, { type: ModuleNameMapper }, { type: ActionNameMapper }, { type: AppStateStore }, { type: i3$1.NgbModal }, { type: i1$2.Router }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EmailListFieldsModule {
    static { this.ɵfac = function EmailListFieldsModule_Factory(t) { return new (t || EmailListFieldsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: EmailListFieldsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailListFieldsModule, [{
        type: NgModule,
        args: [{
                declarations: [EmailListFieldsComponent],
                exports: [EmailListFieldsComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EmailListFieldsModule, { declarations: [EmailListFieldsComponent], imports: [CommonModule], exports: [EmailListFieldsComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharFilterFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        let current = '';
        if (this.field.criteria && this.field.criteria.values && this.field.criteria.values.length > 0) {
            current = this.field.criteria.values[0];
        }
        if (!isVoid(current)) {
            current = current.trim();
        }
        else {
            current = '';
        }
        this.field.value = current;
        const formattedValue = this.typeFormatter.toUserFormat(this.field.type, current, { mode: 'edit' });
        this.field.formControl.setValue(formattedValue);
        this.field.formControl.markAsDirty();
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    setFieldValue(newValue) {
        this.field.value = newValue;
        this.field.criteria.operator = '=';
        this.field.criteria.values = [newValue];
    }
    static { this.ɵfac = function VarcharFilterFieldComponent_Factory(t) { return new (t || VarcharFilterFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: VarcharFilterFieldComponent, selectors: [["scrm-varchar-filter"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 5, consts: [["type", "text", 3, "formControl", "value", "ngClass"]], template: function VarcharFilterFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "input", 0);
        } if (rf & 2) {
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("formControl", ctx.field.formControl)("value", ctx.field.value)("ngClass", ctx.klass);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharFilterFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-varchar-filter', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<input [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n       [formControl]=\"field.formControl\"\n       [value]=\"field.value\"\n       [ngClass]=\"klass\"\n       type=\"text\">\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EnumEditFieldModule {
    static { this.ɵfac = function EnumEditFieldModule_Factory(t) { return new (t || EnumEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: EnumEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            TagInputModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EnumEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [EnumEditFieldComponent],
                exports: [EnumEditFieldComponent],
                imports: [
                    CommonModule,
                    TagInputModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EnumEditFieldModule, { declarations: [EnumEditFieldComponent], imports: [CommonModule,
        TagInputModule,
        FormsModule], exports: [EnumEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MultiEnumDetailFieldModule {
    static { this.ɵfac = function MultiEnumDetailFieldModule_Factory(t) { return new (t || MultiEnumDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MultiEnumDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [MultiEnumDetailFieldComponent],
                exports: [MultiEnumDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MultiEnumDetailFieldModule, { declarations: [MultiEnumDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [MultiEnumDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LegacyEntrypointLinkBuilder {
    getDownloadEntrypointLink(id, type) {
        const queryParams = { entryPoint: 'download', id, type };
        return './index.php' + this.buildQueryString(queryParams);
    }
    buildQueryString(queryParams, exclude = []) {
        let params = new HttpParams();
        Object.keys(queryParams).forEach((param) => {
            if (exclude.includes(param)) {
                return;
            }
            const value = queryParams[param];
            params = params.set(param, value);
        });
        if (params.keys().length > 0) {
            return '?' + params.toString();
        }
        return '';
    }
    static { this.ɵfac = function LegacyEntrypointLinkBuilder_Factory(t) { return new (t || LegacyEntrypointLinkBuilder)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LegacyEntrypointLinkBuilder, factory: LegacyEntrypointLinkBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LegacyEntrypointLinkBuilder, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FileDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay, legacyEntrypointLinkBuilder) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.legacyEntrypointLinkBuilder = legacyEntrypointLinkBuilder;
        this.filenameLink = '';
    }
    ngOnInit() {
        const id = this.record.id;
        const type = this.record.module;
        this.filenameLink = this.legacyEntrypointLinkBuilder.getDownloadEntrypointLink(id, type);
    }
    static { this.ɵfac = function FileDetailFieldComponent_Factory(t) { return new (t || FileDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(LegacyEntrypointLinkBuilder)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FileDetailFieldComponent, selectors: [["scrm-file-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 2, consts: [[1, "clickable", "field-link", 3, "href"]], template: function FileDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementContainerStart(0);
            i0.ɵɵelementStart(1, "a", 0);
            i0.ɵɵtext(2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementContainerEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("href", ctx.filenameLink, i0.ɵɵsanitizeUrl);
            i0.ɵɵadvance(1);
            i0.ɵɵtextInterpolate1(" ", ctx.field.value, " ");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FileDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-file-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container>\n    <a [href]=\"filenameLink\" class=\"clickable field-link\">\n        {{field.value}}\n    </a>\n</ng-container>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: LegacyEntrypointLinkBuilder }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FileDetailFieldModule {
    static { this.ɵfac = function FileDetailFieldModule_Factory(t) { return new (t || FileDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FileDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            RouterModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FileDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [FileDetailFieldComponent],
                exports: [FileDetailFieldComponent],
                imports: [
                    CommonModule,
                    RouterModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FileDetailFieldModule, { declarations: [FileDetailFieldComponent], imports: [CommonModule,
        RouterModule], exports: [FileDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FormatNumberPipe extends DecimalPipe {
    constructor(formatter, locale) {
        super(locale);
        this.formatter = formatter;
        this.locale = locale;
    }
    // eslint-disable-next-line no-dupe-class-members,@typescript-eslint/no-unused-vars
    transform(value, digitsInfo, locale) {
        if (!value) {
            return null;
        }
        return this.formatter.toUserFormat('' + value);
    }
    static { this.ɵfac = function FormatNumberPipe_Factory(t) { return new (t || FormatNumberPipe)(i0.ɵɵdirectiveInject(NumberFormatter, 16), i0.ɵɵdirectiveInject(LOCALE_ID, 16)); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "formatNumber", type: FormatNumberPipe, pure: true }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormatNumberPipe, [{
        type: Pipe,
        args: [{
                name: 'formatNumber'
            }]
    }], function () { return [{ type: NumberFormatter }, { type: undefined, decorators: [{
                type: Inject,
                args: [LOCALE_ID]
            }] }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FloatDetailFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "formatNumber");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, ctx_r0.field.value), "\n");
} }
class FloatDetailFieldComponent extends BaseNumberComponent {
    constructor(userPreferences, systemConfig, typeFormatter, logic, logicDisplay) {
        super(userPreferences, systemConfig, typeFormatter, logic, logicDisplay);
        this.userPreferences = userPreferences;
        this.systemConfig = systemConfig;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function FloatDetailFieldComponent_Factory(t) { return new (t || FloatDetailFieldComponent)(i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FloatDetailFieldComponent, selectors: [["scrm-float-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[4, "ngIf"]], template: function FloatDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, FloatDetailFieldComponent_ng_container_0_Template, 3, 3, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe, FormatNumberPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FloatDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-float-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    {{field.value | formatNumber}}\n</ng-container>\n" }]
    }], function () { return [{ type: UserPreferenceStore }, { type: SystemConfigStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FormatNumberModule {
    static { this.ɵfac = function FormatNumberModule_Factory(t) { return new (t || FormatNumberModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FormatNumberModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FormatNumberModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    FormatNumberPipe
                ],
                exports: [
                    FormatNumberPipe
                ],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FormatNumberModule, { declarations: [FormatNumberPipe], imports: [CommonModule], exports: [FormatNumberPipe] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FloatDetailFieldModule {
    static { this.ɵfac = function FloatDetailFieldModule_Factory(t) { return new (t || FloatDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FloatDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormatNumberModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FloatDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [FloatDetailFieldComponent],
                exports: [FloatDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormatNumberModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FloatDetailFieldModule, { declarations: [FloatDetailFieldComponent], imports: [CommonModule,
        FormatNumberModule], exports: [FloatDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharFilterFieldModule {
    static { this.ɵfac = function VarcharFilterFieldModule_Factory(t) { return new (t || VarcharFilterFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: VarcharFilterFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharFilterFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [VarcharFilterFieldComponent],
                exports: [VarcharFilterFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(VarcharFilterFieldModule, { declarations: [VarcharFilterFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule], exports: [VarcharFilterFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RelateDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function RelateDetailFieldComponent_Factory(t) { return new (t || RelateDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RelateDetailFieldComponent, selectors: [["scrm-relate-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function RelateDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.field.value, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-relate-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{field.value}}\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModalRecordFilterAdapter {
    getConfig(store) {
        return {
            klass: 'light-filter',
            panelMode: 'collapsible',
            isCollapsed: true,
            collapseOnSearch: true,
            savedFilterEdit: false,
            displayHeader: true,
            module: store.recordList.getModule(),
            filter$: store.recordList.criteria$.pipe(map(criteria => {
                return {
                    key: 'default',
                    criteria
                };
            })),
            savedFilters$: of([]),
            searchFields$: store.searchMetadata$.pipe(map((searchMeta) => {
                if (!searchMeta) {
                    return {};
                }
                let type = 'advanced';
                if (!searchMeta.layout.advanced) {
                    type = 'basic';
                }
                return searchMeta.layout[type];
            })),
            listFields: [],
            onClose: () => {
            },
            onSearch: () => {
            },
            updateFilter: (filter, reload = true) => {
                store.recordList.updateSearchCriteria(filter.criteria, reload);
            },
            resetFilter: (reload) => {
                store.recordList.resetSearchCriteria(reload);
            },
            addSavedFilter: (filter) => {
            },
            removeSavedFilter: (filter) => {
            },
            setOpenFilter: (filter) => {
            },
        };
    }
    static { this.ɵfac = function ModalRecordFilterAdapter_Factory(t) { return new (t || ModalRecordFilterAdapter)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ModalRecordFilterAdapter, factory: ModalRecordFilterAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModalRecordFilterAdapter, [{
        type: Injectable
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModalRecordListTableAdapter {
    constructor(systemConfigs, preferences) {
        this.systemConfigs = systemConfigs;
        this.preferences = preferences;
    }
    /**
     * Get table config
     *
     * @param {object} store to use
     * @param {boolean} multiSelect
     * @returns {object} TableConfig
     */
    getTable(store, multiSelect = false) {
        const config = {
            showHeader: true,
            showFooter: true,
            klass: 'light-table',
            module: store.recordList.getModule(),
            columns: store.columns$.pipe(map(columns => this.mapColumns(store, columns))),
            sort$: store.recordList.sort$,
            maxColumns$: of(5),
            loading$: store.recordList.loading$,
            dataSource: store.recordList,
            pagination: store.recordList,
            toggleRecordSelection: (id) => {
                store.recordList.toggleSelection(id);
            },
            updateSorting: (orderBy, sortOrder) => {
                store.recordList.updateSorting(orderBy, sortOrder);
                store.saveCurrentSort();
            },
            maxListHeight: this.preferences.getUserPreference('record_modal_max_height') ?? this.systemConfigs.getConfigValue('record_modal_max_height'),
            paginationType: this.preferences.getUserPreference('record_modal_pagination_type') ?? this.systemConfigs.getConfigValue('record_modal_pagination_type'),
            loadMore: () => {
                const jump = this.preferences.getUserPreference('list_max_entries_per_modal') ?? this.systemConfigs.getConfigValue('list_max_entries_per_modal');
                const pagination = store.recordList.getPagination();
                const currentPageSize = pagination.pageSize || 0;
                const newPageSize = Number(currentPageSize) + Number(jump);
                store.recordList.setPageSize(newPageSize);
                store.recordList.updatePagination(pagination.current);
            },
            allLoaded: () => {
                const pagination = store.recordList.getPagination();
                if (!pagination) {
                    return false;
                }
                if (Number(pagination.pageLast) >= Number(pagination.total)) {
                    return true;
                }
                return Number(pagination.pageSize) >= Number(pagination.total);
            }
        };
        if (multiSelect) {
            config.selection$ = store.recordList.selection$;
            config.selectedCount$ = store.recordList.selectedCount$;
            config.selectedStatus$ = store.recordList.selectedStatus$;
        }
        return config;
    }
    /**
     * Parse and override column definitions
     *
     * @param {object} store to use
     * @param {[]} columns to map
     * @returns {[]} ColumnDefinition[]
     */
    mapColumns(store, columns) {
        const mappedColumns = [];
        columns.forEach(column => {
            const mapped = { ...column };
            const metadata = column.metadata || {};
            mapped.metadata = { ...metadata };
            this.disableRelateFieldsLink(mapped);
            this.addLinkSelectHandler(store, mapped);
            mappedColumns.push(mapped);
        });
        return mappedColumns;
    }
    /**
     * Disable link for relate fields
     *
     * @param {object} definition to update
     */
    disableRelateFieldsLink(definition) {
        if (definition.type !== 'relate') {
            return;
        }
        definition.link = false;
        definition.metadata.link = false;
    }
    /**
     * Add onClick handler for link fields
     *
     * @param {object} store to use
     * @param {object} definition to update
     */
    addLinkSelectHandler(store, definition) {
        if (!definition.link) {
            return;
        }
        definition.metadata.onClick = (field, record) => {
            store.recordList.clearSelection();
            store.recordList.toggleSelection(record.id);
            store.emitLinkClicked();
        };
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListGQL {
    constructor(apollo) {
        this.apollo = apollo;
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
                'meta',
                'records'
            ]
        };
    }
    /**
     * Fetch data either from backend
     *
     * @param {string} module to get from
     * @param {number} limit  page limit
     * @param {number} offset  current offset
     * @param {object} criteria filter criteria
     * @param {object} sort selection
     * @param {object} metadata with the fields to ask for
     * @returns {object} Observable<ApolloQueryResult<any>>
     */
    fetch(module, limit, offset, criteria, sort, metadata) {
        const fields = metadata.fields;
        const queryOptions = {
            query: gql `
              query recordList($module: String!, $limit: Int, $offset: Int, $criteria: Iterable, $sort: Iterable) {
                recordList(module: $module, limit: $limit, offset: $offset, criteria: $criteria, sort: $sort) {
                  ${fields.join('\n')}
                }
              }
            `,
            variables: {
                module,
                limit,
                offset,
                criteria,
                sort
            },
        };
        return this.apollo.query(queryOptions);
    }
    /**
     * Fetch the List records from the backend
     *
     * @param {string} module to use
     * @param {object} criteria to use
     * @param {object} sort to use
     * @param {object} pagination to use
     * @returns {object} Observable<any>
     */
    get(module, criteria, sort, pagination) {
        const mappedSort = this.mapSort(sort);
        return this.fetch(module, toInteger(pagination.pageSize), toInteger(pagination.current), criteria, mappedSort, this.fieldsMetadata)
            .pipe(map(({ data }) => {
            const recordsList = {
                records: [],
                pagination: { ...pagination }
            };
            if (!data || !data.recordList) {
                return recordsList;
            }
            const listData = data.recordList;
            if (listData.records) {
                listData.records.forEach((record) => {
                    recordsList.records.push(this.mapRecord(record));
                });
            }
            if (!listData.meta) {
                return recordsList;
            }
            if (listData.meta.offsets) {
                const paginationFieldMap = {
                    current: 'current',
                    next: 'next',
                    prev: 'previous',
                    total: 'total',
                    end: 'last',
                };
                Object.keys(paginationFieldMap).forEach((key) => {
                    if (key in listData.meta.offsets) {
                        const paginationField = paginationFieldMap[key];
                        recordsList.pagination[paginationField] = listData.meta.offsets[key];
                    }
                });
            }
            recordsList.meta = listData.meta;
            return recordsList;
        }));
    }
    /**
     * Map sort.
     * @param {object} sort to map
     */
    mapSort(sort) {
        const sortOrderMap = {
            NONE: '',
            ASC: 'ASC',
            DESC: 'DESC'
        };
        return {
            sortOrder: sortOrderMap[sort.sortOrder],
            orderBy: sort.orderBy
        };
    }
    /**
     * Map record. Allow for extensions
     * @param record
     */
    mapRecord(record) {
        return record;
    }
    static { this.ɵfac = function ListGQL_Factory(t) { return new (t || ListGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListGQL, factory: ListGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialFilter$1 = {
    key: 'default',
    module: 'saved-search',
    attributes: {
        contents: ''
    },
    criteria: {
        name: 'default',
        filters: {}
    }
};
const initialFilters$1 = {
    'default': deepClone(initialFilter$1)
};
const initialSearchCriteria = {
    filters: {}
};
const initialListSort = {
    orderBy: '',
    sortOrder: SortDirection.DESC
};
const initialListPagination = {
    pageSize: 5,
    current: 0,
    previous: 0,
    next: 5,
    last: 0,
    total: 0,
    pageFirst: 0,
    pageLast: 0
};
const initialSelection = {
    all: false,
    status: SelectionStatus.NONE,
    selected: {},
    count: 0
};
const initialState$i = {
    module: '',
    records: [],
    criteria: deepClone(initialSearchCriteria),
    activeFilters: deepClone(initialFilters$1),
    sort: deepClone(initialListSort),
    pagination: deepClone(initialListPagination),
    selection: deepClone(initialSelection),
    openFilter: deepClone(initialFilter$1),
    loading: false,
    meta: {}
};
class RecordListStore {
    constructor(listGQL, configStore, preferencesStore, languageStore, message, localStorageService) {
        this.listGQL = listGQL;
        this.configStore = configStore;
        this.preferencesStore = preferencesStore;
        this.languageStore = languageStore;
        this.message = message;
        this.localStorageService = localStorageService;
        /** Internal Properties */
        this.cache$ = null;
        this.internalState = deepClone(initialState$i);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subs = [];
        this.pageKey = null;
        this.records$ = this.state$.pipe(map(state => state.records), distinctUntilChanged());
        this.criteria$ = this.state$.pipe(map(state => state.criteria), distinctUntilChanged());
        this.sort$ = this.state$.pipe(map(state => state.sort), distinctUntilChanged());
        this.pagination$ = this.state$.pipe(map(state => state.pagination), distinctUntilChanged());
        this.selection$ = this.state$.pipe(map(state => state.selection), distinctUntilChanged());
        this.selectedCount$ = this.state$.pipe(map(state => state.selection.count), distinctUntilChanged());
        this.selectedStatus$ = this.state$.pipe(map(state => state.selection.status), distinctUntilChanged());
        this.activeFilters$ = this.state$.pipe(map(state => state.activeFilters), distinctUntilChanged());
        this.openFilter$ = this.state$.pipe(map(state => state.openFilter), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading));
    }
    connect() {
        return this.records$;
    }
    disconnect() {
    }
    get criteria() {
        if (!this.internalState.criteria) {
            return deepClone(initialSearchCriteria);
        }
        return deepClone(this.internalState.criteria);
    }
    set criteria(criteria) {
        this.updateState({
            ...this.internalState,
            criteria
        });
    }
    get activeFilters() {
        return deepClone(this.internalState.activeFilters);
    }
    get sort() {
        if (!this.internalState.sort) {
            return deepClone(initialListSort);
        }
        return deepClone(this.internalState.sort);
    }
    set sort(sort) {
        this.updateState({
            ...this.internalState,
            sort
        });
    }
    get pagination() {
        if (!this.internalState.pagination) {
            return deepClone(initialListPagination);
        }
        return deepClone(this.internalState.pagination);
    }
    set pagination(pagination) {
        this.updateState({
            ...this.internalState,
            pagination
        });
    }
    get selection() {
        if (!this.internalState.selection) {
            return deepClone(initialSelection);
        }
        return deepClone(this.internalState.selection);
    }
    get records() {
        if (!this.internalState.records) {
            return [];
        }
        return this.internalState.records;
    }
    getModule() {
        return this.internalState.module;
    }
    getRecord(id) {
        let record = null;
        this.records.some(item => {
            if (item.id === id) {
                record = item;
                return true;
            }
        });
        return record;
    }
    /**
     * Clean destroy
     */
    destroy() {
        this.clear();
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {boolean} load if to load
     * @param {string} pageSizeConfigKey string
     * @param filter
     * @param preferenceKey
     * @returns {object} Observable<any>
     */
    init(module, load = true, pageSizeConfigKey = 'list_max_entries_per_page', filter = deepClone(initialFilter$1), preferenceKey = '') {
        this.internalState.module = module;
        this.preferenceKey = preferenceKey;
        if (pageSizeConfigKey) {
            this.watchPageSize(pageSizeConfigKey);
        }
        this.setBaseFilter(filter);
        this.loadCurrentFilter(module);
        if (load === false) {
            return null;
        }
        return this.load();
    }
    setBaseFilter(filter) {
        this.baseFilterMap = { 'default': deepClone(filter) };
        this.baseFilter = deepClone(filter);
        this.updateState({ ...this.internalState, activeFilters: deepClone(this.baseFilterMap), openFilter: deepClone(this.baseFilter) });
    }
    /**
     * Load current filter
     * @param module
     * @protected
     */
    loadCurrentFilter(module) {
        const activeFiltersPref = this.loadPreference(module, 'current-filters') ?? this.baseFilterMap;
        if (!activeFiltersPref || emptyObject(activeFiltersPref)) {
            return;
        }
        let currentSort = this.loadPreference(module, 'current-sort');
        if (!currentSort && emptyObject(currentSort)) {
            currentSort = null;
        }
        this.setFilters(activeFiltersPref, false, currentSort);
    }
    /**
     * Set active filters
     *
     * @param {object} filters to set
     * @param {boolean} reload flag
     * @param sort
     */
    setFilters(filters, reload = true, sort = null) {
        const filterKey = Object.keys(filters).shift();
        const filter = filters[filterKey];
        this.updateState({ ...this.internalState, activeFilters: deepClone(filters), openFilter: deepClone(filter) });
        if (filter.criteria) {
            let orderBy = filter.criteria.orderBy ?? '';
            const sortOrder = filter.criteria.sortOrder ?? 'desc';
            let direction = this.mapSortOrder(sortOrder);
            if (sort !== null) {
                orderBy = sort.orderBy;
                direction = sort.sortOrder;
            }
            this.updateSorting(orderBy, direction, false);
            this.updateSortLocalStorage();
            this.updateSearchCriteria(filter.criteria, reload);
        }
        this.updateFilterLocalStorage();
    }
    updateFilterLocalStorage() {
        const module = this.internalState.module;
        this.savePreference(module, 'current-filters', this.internalState.activeFilters);
    }
    updateSortLocalStorage() {
        const module = this.internalState.module;
        this.savePreference(module, 'current-sort', this.sort);
    }
    updatePaginationLocalStorage() {
        if (this.pageKey === null) {
            return;
        }
        const module = this.internalState.module;
        const key = module + '-' + this.pageKey + '-' + 'current-pagination';
        this.localStorageService.set(key, this.pagination);
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<ListViewState>
     */
    load(useCache = true) {
        this.updateState({
            ...this.internalState,
            loading: true
        });
        return this.getRecords(this.internalState.module, this.internalState.criteria, this.internalState.sort, this.internalState.pagination, useCache).pipe(catchError(() => {
            this.message.addDangerMessageByKey('LBL_GET_RECORD_LIST_ERROR');
            return of({
                records: [],
                criteria: deepClone(initialSearchCriteria),
                sort: deepClone(initialListSort),
                pagination: deepClone(initialListPagination),
                openFilter: deepClone(this.baseFilter),
                activeFilters: deepClone(this.baseFilterMap),
                selection: deepClone(initialSelection),
                meta: {}
            });
        }), tap((data) => {
            this.calculatePageCount(data.records, data.pagination);
            this.updateState({
                ...this.internalState,
                records: data.records,
                pagination: data.pagination,
                loading: false,
                meta: data.meta ?? {}
            });
        }));
    }
    /**
     * Update the search criteria
     *
     * @param {object} criteria to set
     * @param {boolean} reload flag
     */
    updateSearchCriteria(criteria, reload = true) {
        this.updateState({ ...this.internalState, criteria });
        if (reload) {
            this.updateSelection(SelectionStatus.NONE);
            // Reset pagination to default first page
            this.resetPagination();
        }
    }
    /**
     * Reset search criteria
     * @param {boolean} reload flag
     */
    resetSearchCriteria(reload = true) {
        this.updateSearchCriteria(deepClone(initialSearchCriteria), reload);
    }
    /**
     * Update current list view sorting
     *
     * @param {string} orderBy to set
     * @param {string} sortOrder to set
     * @param {boolean} reload flag
     */
    updateSorting(orderBy, sortOrder, reload = true) {
        if (sortOrder === SortDirection.NONE) {
            orderBy = '';
            sortOrder = SortDirection.DESC;
        }
        const sort = { orderBy, sortOrder };
        this.updateState({ ...this.internalState, sort });
        if (reload) {
            this.load(false).pipe(take(1)).subscribe();
        }
    }
    /**
     * Map sort order to SortDirection enum
     * @param {string} sortOrder to map
     * @returns {string} SortDirection
     */
    mapSortOrder(sortOrder) {
        let direction = SortDirection.NONE;
        const sort = sortOrder.toLowerCase();
        if (sort === 'asc') {
            direction = SortDirection.ASC;
        }
        else if (sort === 'desc') {
            direction = SortDirection.DESC;
        }
        return direction;
    }
    /**
     * Update the pagination
     *
     * @param {number} current to set
     */
    updatePagination(current) {
        const pagination = { ...this.internalState.pagination, current };
        this.updateState({ ...this.internalState, pagination });
        this.load(false).pipe(take(1), tap(() => this.updatePaginationLocalStorage())).subscribe();
    }
    setPagination(current) {
        const pagination = { ...this.internalState.pagination, current };
        this.updateState({ ...this.internalState, pagination });
        return this.load(false).pipe(take(1), tap(() => this.updatePaginationLocalStorage()));
    }
    /**
     * Set open filters
     *
     * @param {object} filter to set
     */
    setOpenFilter(filter) {
        this.updateState({ ...this.internalState, openFilter: deepClone(filter) });
    }
    /**
     * Reset active filters
     *
     * @param {boolean} reload flag
     */
    resetFilters(reload = true) {
        this.updateState({
            ...this.internalState,
            activeFilters: deepClone(this.baseFilterMap),
            openFilter: deepClone(this.baseFilter),
        });
        this.clearSort();
        this.updateSortLocalStorage();
        this.updateFilterLocalStorage();
        this.updateSearchCriteria(this.baseFilter.criteria, reload);
    }
    /**
     * Save ui user preference
     * @param module
     * @param storageKey
     * @param value
     * @protected
     */
    savePreference(module, storageKey, value) {
        const preferenceKey = this.preferenceKey ?? null;
        if (!preferenceKey) {
            return null;
        }
        const key = `${preferenceKey}${storageKey}`;
        this.preferencesStore.setUi(module, key, value);
    }
    /**
     * Load ui user preference
     * @param module
     * @param storageKey
     * @protected
     */
    loadPreference(module, storageKey) {
        const preferenceKey = this.preferenceKey ?? null;
        if (!preferenceKey) {
            return null;
        }
        const key = `${preferenceKey}${storageKey}`;
        return this.preferencesStore.getUi(module, key);
    }
    /**
     * Reset/Clear the pagination
     */
    resetPagination() {
        this.updatePagination(0);
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.cache$ = null;
        this.store.unsubscribe();
        this.preferencesSub.unsubscribe();
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Selection public api
     */
    getSelectionStatus() {
        return this.selectedStatus$;
    }
    getSelectedCount() {
        return this.selectedCount$;
    }
    updateSelection(state) {
        if (state === SelectionStatus.NONE) {
            this.clearSelection();
            return;
        }
        if (state === SelectionStatus.ALL) {
            this.selectAll();
            return;
        }
        if (state === SelectionStatus.PAGE) {
            this.selectPage();
            return;
        }
    }
    clearSelection() {
        this.updateState({
            ...this.internalState,
            selection: deepClone(initialSelection)
        });
    }
    clearSort() {
        this.updateState({
            ...this.internalState,
            sort: deepClone(initialListSort)
        });
    }
    selectAll() {
        const total = this.internalState.pagination.total;
        this.updateState({
            ...this.internalState,
            selection: {
                all: true,
                status: SelectionStatus.ALL,
                selected: {},
                count: total
            }
        });
    }
    selectPage() {
        const selected = { ...this.internalState.selection.selected };
        if (this.internalState.records && this.internalState.records.length) {
            this.internalState.records.forEach(value => {
                if (value && value.id) {
                    selected[value.id] = value.id;
                }
            });
        }
        this.updateState({
            ...this.internalState,
            selection: {
                all: false,
                status: SelectionStatus.SOME,
                selected,
                count: Object.keys(selected).length
            }
        });
    }
    toggleSelection(id) {
        const selection = deepClone(this.internalState.selection);
        if (selection.selected[id]) {
            delete selection.selected[id];
        }
        else {
            selection.selected[id] = id;
        }
        selection.count = Object.keys(selection.selected).length;
        if (selection.count === 0) {
            selection.status = SelectionStatus.NONE;
        }
        else {
            selection.status = SelectionStatus.SOME;
        }
        this.updateState({
            ...this.internalState,
            selection
        });
    }
    /**
     * Pagination Public API
     */
    getPaginationCount() {
        return this.pagination$.pipe(map(pagination => ({
            pageFirst: pagination.pageFirst,
            pageLast: pagination.pageLast,
            total: pagination.total
        })), distinctUntilChanged());
    }
    getPagination() {
        return this.store.value.pagination;
    }
    getMeta() {
        return this.store.value.meta;
    }
    changePage(page) {
        let pageToLoad = 0;
        const pageMap = {};
        pageMap[PageSelection.FIRST] = 0;
        pageMap[PageSelection.PREVIOUS] = this.internalState.pagination.previous;
        pageMap[PageSelection.NEXT] = this.internalState.pagination.next;
        pageMap[PageSelection.LAST] = this.internalState.pagination.last;
        if (page in pageMap && pageMap[page] >= 0) {
            pageToLoad = pageMap[page];
            if (Number(pageToLoad) > this.internalState.pagination.last) {
                return;
            }
            if (pageToLoad < 0) {
                return;
            }
            this.updatePagination(pageToLoad);
        }
    }
    setPage(page, isPaginationLoadMore) {
        let pageToLoad = 0;
        const pageMap = {};
        pageMap[PageSelection.FIRST] = 0;
        pageMap[PageSelection.PREVIOUS] = this.internalState.pagination.previous;
        pageMap[PageSelection.NEXT] = this.internalState.pagination.next;
        pageMap[PageSelection.LAST] = this.internalState.pagination.last;
        if (page in pageMap && pageMap[page] >= 0) {
            pageToLoad = pageMap[page];
            if (Number(pageToLoad) > this.internalState.pagination.last) {
                return of({});
            }
            if (pageToLoad < 0) {
                return of({});
            }
            if (isPaginationLoadMore) {
                pageToLoad = 0;
            }
            return this.setPagination(pageToLoad);
        }
        return of({});
    }
    /**
     * Set Pagination page size
     *
     * @param {number} pageSize to set
     */
    setPageSize(pageSize) {
        const pagination = { ...this.internalState.pagination, pageSize };
        this.updateState({ ...this.internalState, pagination });
    }
    /**
     * Get Pagination page size
     */
    getPageSize() {
        return this?.internalState?.pagination?.pageSize ?? 10;
    }
    /**
     * Internal API
     */
    /**
     * Subscribe to page size changes
     *
     * @param {string} pageSizeConfigKey key
     */
    watchPageSize(pageSizeConfigKey) {
        const pageSizePreference = this.preferencesStore.getUserPreference(pageSizeConfigKey);
        const pageSizeConfig = this.configStore.getConfigValue(pageSizeConfigKey);
        this.determinePageSize(pageSizePreference, pageSizeConfig);
        this.preferencesSub = this.configStore.configs$.pipe(combineLatestWith(this.preferencesStore.userPreferences$), tap(([configs, preferences]) => {
            const key = pageSizeConfigKey;
            const sizePreference = (preferences && preferences[key]) || null;
            const sizeConfig = (configs && configs[key] && configs[key].value) || null;
            this.determinePageSize(sizePreference, sizeConfig);
        })).subscribe();
    }
    /**
     * Determine page size to use
     *
     * @param {} pageSizePreference to use
     * @param {string} pageSizeConfig to use
     */
    determinePageSize(pageSizePreference, pageSizeConfig) {
        let size = 20;
        if (pageSizePreference) {
            size = pageSizePreference;
        }
        else if (pageSizeConfig) {
            size = parseInt(pageSizeConfig, 10);
        }
        this.setPageSize(size);
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Calculate page count
     *
     * @param {object} records list
     * @param {object} pagination info
     */
    calculatePageCount(records, pagination) {
        const recordCount = (records && records.length) || 0;
        let pageFirst = 0;
        let pageLast = 0;
        if (recordCount > 0) {
            pageFirst = pagination.current + 1;
            pageLast = pagination.current + recordCount;
        }
        pagination.pageFirst = pageFirst;
        pagination.pageLast = pageLast;
    }
    /**
     * Get records cached Observable or call the backend
     *
     * @param {string} module to use
     * @param {object} criteria to use
     * @param {object} sort to use
     * @param {object} pagination to use
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<any>
     */
    getRecords(module, criteria, sort, pagination, useCache = true) {
        if (this.cache$ == null || useCache === false) {
            this.cache$ = this.listGQL.get(module, criteria, sort, pagination).pipe(shareReplay(1));
        }
        return this.cache$;
    }
    static { this.ɵfac = function RecordListStore_Factory(t) { return new (t || RecordListStore)(i0.ɵɵinject(ListGQL), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordListStore, factory: RecordListStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListStore, [{
        type: Injectable
    }], function () { return [{ type: ListGQL }, { type: SystemConfigStore }, { type: UserPreferenceStore }, { type: LanguageStore }, { type: MessageService }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordListStoreFactory {
    constructor(listGQL, configStore, preferencesStore, languageStore, message, localStorageService) {
        this.listGQL = listGQL;
        this.configStore = configStore;
        this.preferencesStore = preferencesStore;
        this.languageStore = languageStore;
        this.message = message;
        this.localStorageService = localStorageService;
    }
    create() {
        return new RecordListStore(this.listGQL, this.configStore, this.preferencesStore, this.languageStore, this.message, this.localStorageService);
    }
    static { this.ɵfac = function RecordListStoreFactory_Factory(t) { return new (t || RecordListStoreFactory)(i0.ɵɵinject(ListGQL), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordListStoreFactory, factory: RecordListStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: ListGQL }, { type: SystemConfigStore }, { type: UserPreferenceStore }, { type: LanguageStore }, { type: MessageService }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$h = {
    module: '',
    detailView: {},
    editView: {},
    listView: {},
    search: {},
    recordView: {},
    subPanel: {},
    massUpdate: {},
    recentlyViewed: [],
    favorites: [],
    fieldActions: {}
};
const initialModuleMetadataState = {};
let internalState$5 = deepClone(initialState$h);
let allModulesState = deepClone(initialModuleMetadataState);
const initialCache = {};
let cache = deepClone(initialCache);
class MetadataStore {
    constructor(recordGQL, appState) {
        this.recordGQL = recordGQL;
        this.appState = appState;
        this.typeKeys = {
            listView: 'listView',
            search: 'search',
            recordView: 'recordView',
            subPanel: 'subPanel',
            massUpdate: 'massUpdate',
            recentlyViewed: 'recentlyViewed',
            favorites: 'favorites'
        };
        this.store = new BehaviorSubject(internalState$5);
        this.state$ = this.store.asObservable();
        this.allModuleStore = new BehaviorSubject(allModulesState);
        this.allModulesState$ = this.allModuleStore.asObservable();
        this.resourceName = 'moduleMetadata';
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
            ]
        };
        this.types = [
            'listView',
            'search',
            'recordView',
            'subPanel',
            'massUpdate',
            'recentlyViewed',
            'favorites'
        ];
        this.baseTypes = [
            'listView',
            'search',
            'recordView',
            'favorites'
        ];
        this.listViewColumns$ = this.state$.pipe(map(state => state.listView.fields), distinctUntilChanged());
        this.listViewLineActions$ = this.state$.pipe(map(state => state.listView.lineActions), distinctUntilChanged());
        this.listViewTableActions$ = this.state$.pipe(map(state => state.listView.tableActions), distinctUntilChanged());
        this.listMetadata$ = this.state$.pipe(map(state => state.listView), distinctUntilChanged());
        this.searchMetadata$ = this.state$.pipe(map(state => state.search), distinctUntilChanged());
        this.recordViewMetadata$ = this.state$.pipe(map(state => state.recordView), distinctUntilChanged());
        this.fieldActions$ = this.state$.pipe(map(state => state.fieldActions), distinctUntilChanged());
        this.subPanelMetadata$ = this.state$.pipe(map(state => state.subPanel), distinctUntilChanged());
        this.metadata$ = this.state$;
        this.allModuleMetadata$ = this.allModulesState$;
    }
    /**
     * Clear state
     */
    clear() {
        cache = deepClone(initialCache);
        allModulesState = deepClone(initialModuleMetadataState);
        this.updateState('', deepClone(initialState$h));
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get all metadata types
     *
     * @returns {string[]} metadata types
     */
    getMetadataTypes() {
        return this.types;
    }
    getModule() {
        return internalState$5.module;
    }
    get() {
        return internalState$5;
    }
    getModuleMeta(module) {
        const meta = allModulesState[module] ?? {};
        return { ...meta };
    }
    setModuleMetadata(module, metadata) {
        cache[module] = of(metadata).pipe(shareReplay(1));
        this.updateAllModulesState(module, metadata);
    }
    /**
     * Initial ListViewMeta load if not cached and update state.
     *
     * @param {string} moduleID to fetch
     * @param {string[]} types to fetch
     * @param useCache
     * @returns any data
     */
    reloadModuleMetadata(moduleID, types, useCache = true) {
        if (!types) {
            types = this.getMetadataTypes();
        }
        return this.getMetadata(moduleID, types, useCache).pipe(tap((metadata) => {
            this.updateAllModulesState(moduleID, metadata);
        }));
    }
    /**
     * Initial ListViewMeta load if not cached and update state.
     *
     * @param {string} moduleID to fetch
     * @param {string[]} types to fetch
     * @param useCache
     * @returns any data
     */
    load(moduleID, types, useCache = true) {
        if (!types) {
            types = this.getMetadataTypes();
        }
        return this.getMetadata(moduleID, types, useCache).pipe(tap((metadata) => {
            this.updateState(moduleID, metadata);
        }));
    }
    /**
     * Check if loaded
     */
    isCached(module) {
        return (cache[module] ?? null) !== null;
    }
    /**
     * Get empty Metadata
     */
    getEmpty() {
        return deepClone(initialState$h);
    }
    /**
     * Set pre-loaded navigation and cache
     */
    set(module, metadata) {
        cache[module] = of(metadata).pipe(shareReplay(1));
        this.updateState(module, metadata);
    }
    /**
     * Get ListViewMeta cached Observable or call the backend
     *
     * @param {string} module to fetch
     * @param {string[]} types to retrieve
     * @param useCache
     * @returns {object} Observable<any>
     */
    getMetadata(module, types = null, useCache = true) {
        if (cache[module] == null || useCache === false) {
            cache[module] = this.fetchMetadata(module, types).pipe(shareReplay(1));
        }
        return cache[module];
    }
    /**
     * Internal API
     */
    mapMetadata(module, data) {
        const moduleMetadata = allModulesState[module] ?? {};
        const metadata = { ...moduleMetadata };
        this.parseListViewMetadata(data, metadata);
        this.parseSearchMetadata(data, metadata);
        this.parseRecordViewMetadata(data, metadata);
        this.parseSubPanelMetadata(data, metadata);
        this.parseMassUpdateMetadata(data, metadata);
        this.parseRecentlyViewedMetadata(data, metadata);
        this.parseFavoritesMetadata(data, metadata);
        this.parseFieldViewMetada(data, metadata);
        return metadata;
    }
    /**
     * Update the state
     *
     * @param {string} module
     * @param {object} state to set
     */
    updateState(module, state) {
        this.updateAllModulesState(module, state);
        this.store.next(internalState$5 = { ...state, module });
    }
    /**
     * Update the state
     *
     * @param {string} module
     * @param {object} state to set
     */
    updateAllModulesState(module, state) {
        if (module !== '') {
            const newState = {
                ...allModulesState
            };
            newState[module] = { ...state };
            this.allModuleStore.next(allModulesState = newState);
        }
    }
    /**
     * Fetch the Metadata from the backend
     *
     * @param {string} module to fetch
     * @param {string[]} types to retrieve
     * @returns {object} Observable<{}>
     */
    fetchMetadata(module, types) {
        const fieldsToRetrieve = {
            fields: [
                ...this.fieldsMetadata.fields,
                ...(types ?? this.baseTypes)
            ]
        };
        return this.recordGQL.fetch(this.resourceName, `/api/module-metadata/${module}`, fieldsToRetrieve)
            .pipe(map(({ data }) => {
            return this.mapMetadata(module, data.moduleMetadata);
        }));
    }
    parseListViewMetadata(data, metadata) {
        if (!data || !data.listView) {
            return;
        }
        const listViewMeta = {
            fields: [],
            bulkActions: {},
            lineActions: [],
            tableActions: [],
            chartTypes: {},
            filters: []
        };
        if (data.listView.columns) {
            data.listView.columns.forEach((field) => {
                listViewMeta.fields.push(field);
            });
        }
        const entries = {
            bulkActions: 'bulkActions',
            lineActions: 'lineActions',
            tableActions: 'tableActions',
            sidebarWidgets: 'sidebarWidgets',
            availableFilters: 'filters',
            paginationType: 'paginationType'
        };
        this.addDefinedMeta(listViewMeta, data.listView, entries);
        metadata.listView = listViewMeta;
    }
    parseFieldViewMetada(data, metadata) {
        if (!data || !data.recordView || !data.recordView.panels) {
            return;
        }
        const fieldActions = {
            recordView: {}
        };
        data.recordView.panels.forEach(panel => {
            if (panel.rows) {
                panel.rows.forEach(row => {
                    if (row.cols) {
                        row.cols.forEach(col => {
                            if (col.fieldActions && col.fieldActions.actions) {
                                Object.values(col.fieldActions.actions).forEach(action => {
                                    action['fieldName'] = col.name;
                                    const viewFieldActions = fieldActions['recordView'][col.name] ?? [];
                                    viewFieldActions.push(action);
                                    fieldActions['recordView'][col.name] = viewFieldActions;
                                });
                            }
                        });
                    }
                });
            }
        });
        metadata.fieldActions = fieldActions;
    }
    parseSearchMetadata(data, metadata) {
        if (data && data.search) {
            metadata.search = data.search;
        }
    }
    parseSubPanelMetadata(data, metadata) {
        if (data && data.subPanel) {
            metadata.subPanel = data.subPanel;
        }
    }
    parseMassUpdateMetadata(data, metadata) {
        if (data && data.massUpdate) {
            metadata.massUpdate = data.massUpdate;
        }
    }
    parseRecordViewMetadata(data, metadata) {
        if (!data || !data.recordView) {
            return;
        }
        const recordViewMeta = {
            actions: [],
            templateMeta: {},
            panels: []
        };
        const receivedMeta = data.recordView;
        const entries = {
            templateMeta: 'templateMeta',
            actions: 'actions',
            panels: 'panels',
            topWidget: 'topWidget',
            sidebarWidgets: 'sidebarWidgets',
            bottomWidgets: 'bottomWidgets',
            summaryTemplates: 'summaryTemplates',
            vardefs: 'vardefs',
            metadata: 'metadata'
        };
        this.addDefinedMeta(recordViewMeta, receivedMeta, entries);
        metadata.recordView = recordViewMeta;
    }
    parseRecentlyViewedMetadata(data, metadata) {
        if (data && data.recentlyViewed) {
            metadata.recentlyViewed = data.recentlyViewed;
        }
    }
    parseFavoritesMetadata(data, metadata) {
        if (data && data.favorites) {
            metadata.favorites = data.favorites;
        }
    }
    addDefinedMeta(metadata, received, keyMap) {
        Object.keys(keyMap).forEach(dataKey => {
            const metadataKey = keyMap[dataKey];
            if (received[dataKey]) {
                metadata[metadataKey] = received[dataKey];
            }
        });
    }
    static { this.ɵfac = function MetadataStore_Factory(t) { return new (t || MetadataStore)(i0.ɵɵinject(EntityGQL), i0.ɵɵinject(AppStateStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MetadataStore, factory: MetadataStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MetadataStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityGQL }, { type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordListModalStore {
    constructor(listStoreFactory, meta, preferences) {
        this.listStoreFactory = listStoreFactory;
        this.meta = meta;
        this.preferences = preferences;
        this.module = '';
        this.parentModule = '';
        this.recordList = listStoreFactory.create();
        this.loading$ = this.recordList.loading$;
        this.metadataLoadingState = new BehaviorSubject(false);
        this.linkClickedState = new BehaviorSubject(false);
        this.linkClicked$ = this.linkClickedState.asObservable();
        this.metadataLoading$ = this.metadataLoadingState.asObservable();
        this.selection$ = this.recordList.selection$;
        this.selectedCount$ = this.recordList.selectedCount$;
        this.selectedStatus$ = this.recordList.selectedStatus$;
    }
    clear() {
        this.recordList.clear();
        this.recordList = null;
    }
    clearAuthBased() {
        this.recordList.clearAuthBased();
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module name
     * @param {string} parentModule
     */
    init(module, parentModule = '') {
        this.module = module;
        this.parentModule = parentModule;
        this.loadCurrentSort();
        this.metadataLoadingState.next(true);
        const meta$ = this.meta.getMetadata(module).pipe(tap(() => {
            this.metadataLoadingState.next(false);
            this.recordList.load().pipe(take(1)).subscribe();
        }));
        this.listMetadata$ = meta$.pipe(map(meta => meta.listView));
        this.searchMetadata$ = meta$.pipe(map(meta => meta.search));
        this.recordList.init(module, false, 'list_max_entries_per_modal');
        this.columns$ = this.listMetadata$.pipe(map(metadata => metadata.fields));
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordList>
     */
    load(useCache = true) {
        return this.recordList.load(useCache);
    }
    /**
     * Load current sorting
     */
    loadCurrentSort() {
        if (!this.parentModule) {
            return;
        }
        const currentSort = this.loadPreference(this.parentModule, 'current-sort');
        if (!currentSort || emptyObject(currentSort)) {
            return;
        }
        this.recordList.sort = currentSort;
    }
    /**
     * Load current sorting
     */
    saveCurrentSort() {
        if (!this.parentModule) {
            return;
        }
        this.savePreference(this.parentModule, 'current-sort', this.recordList.sort);
    }
    /**
     * Emit Clicked Event
     */
    emitLinkClicked() {
        this.linkClickedState.next(true);
    }
    /**
     * Build ui user preference key
     * @param storageKey
     * @protected
     */
    getPreferenceKey(storageKey) {
        return this.module + '-record-list-modal-' + storageKey;
    }
    /**
     * Save ui user preference
     * @param module
     * @param storageKey
     * @param value
     * @protected
     */
    savePreference(module, storageKey, value) {
        this.preferences.setUi(module, this.getPreferenceKey(storageKey), value);
    }
    /**
     * Load ui user preference
     * @param parentModule
     * @param storageKey
     * @protected
     */
    loadPreference(parentModule, storageKey) {
        return this.preferences.getUi(parentModule, this.getPreferenceKey(storageKey));
    }
    static { this.ɵfac = function RecordListModalStore_Factory(t) { return new (t || RecordListModalStore)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordListModalStore, factory: RecordListModalStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListModalStore, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }, { type: MetadataStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordListModalStoreFactory {
    constructor(listStoreFactory, metadataStore, preferences) {
        this.listStoreFactory = listStoreFactory;
        this.metadataStore = metadataStore;
        this.preferences = preferences;
    }
    create() {
        return new RecordListModalStore(this.listStoreFactory, this.metadataStore, this.preferences);
    }
    static { this.ɵfac = function RecordListModalStoreFactory_Factory(t) { return new (t || RecordListModalStoreFactory)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordListModalStoreFactory, factory: RecordListModalStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListModalStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordListStoreFactory }, { type: MetadataStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MaxColumnsCalculator {
    constructor(screenSize, systemConfigStore) {
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.screen = ScreenSize.Medium;
        this.maxColumns = 5;
    }
    getMaxColumns(sidebarActive$) {
        return sidebarActive$.pipe(combineLatestWith(this.screenSize.screenSize$), map(([sidebarActive, screenSize]) => {
            if (screenSize) {
                this.screen = screenSize;
            }
            return this.calculateMaxColumns(sidebarActive);
        }), distinctUntilChanged());
    }
    calculateMaxColumns(sideBar = true) {
        let sizeMap;
        sizeMap = this.systemConfigStore.getConfigValue('listview_column_limits');
        if (sideBar) {
            sizeMap = sizeMap.with_sidebar;
        }
        else {
            sizeMap = sizeMap.without_sidebar;
        }
        if (this.screen && sizeMap) {
            const maxCols = sizeMap[this.screen];
            if (maxCols) {
                this.maxColumns = maxCols;
            }
        }
        return this.maxColumns;
    }
    static { this.ɵfac = function MaxColumnsCalculator_Factory(t) { return new (t || MaxColumnsCalculator)(i0.ɵɵinject(ScreenSizeObserverService), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MaxColumnsCalculator, factory: MaxColumnsCalculator.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MaxColumnsCalculator, [{
        type: Injectable
    }], function () { return [{ type: ScreenSizeObserverService }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordListModalComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 3);
    i0.ɵɵelementContainerEnd();
} }
function RecordListModalComponent_ng_container_3_scrm_list_filter_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-list-filter", 9);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config", ctx_r2.filterConfig);
} }
function RecordListModalComponent_ng_container_3_ng_container_9_scrm_loading_spinner_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-loading-spinner", 11);
} if (rf & 2) {
    i0.ɵɵproperty("overlay", true);
} }
function RecordListModalComponent_ng_container_3_ng_container_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordListModalComponent_ng_container_3_ng_container_9_scrm_loading_spinner_1_Template, 1, 1, "scrm-loading-spinner", 10);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const loading_r5 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", loading_r5);
} }
function RecordListModalComponent_ng_container_3_ng_container_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r4.buildSelectButton());
} }
function RecordListModalComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div")(2, "div", 4)(3, "div", 5)(4, "div", 6);
    i0.ɵɵtemplate(5, RecordListModalComponent_ng_container_3_scrm_list_filter_5_Template, 1, 1, "scrm-list-filter", 7);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 8)(7, "div", 6);
    i0.ɵɵelement(8, "scrm-table", 9);
    i0.ɵɵelementEnd()()();
    i0.ɵɵtemplate(9, RecordListModalComponent_ng_container_3_ng_container_9_Template, 2, 1, "ng-container", 2);
    i0.ɵɵpipe(10, "async");
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(11, RecordListModalComponent_ng_container_3_ng_container_11_Template, 2, 1, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r1.filterConfig);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("config", ctx_r1.tableConfig);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(10, 4, ctx_r1.loading$));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r1.multiSelect);
} }
class RecordListModalComponent {
    constructor(activeModal, storeFactory, languages, maxColumnCalculator, preferences, systemConfigs) {
        this.activeModal = activeModal;
        this.storeFactory = storeFactory;
        this.languages = languages;
        this.maxColumnCalculator = maxColumnCalculator;
        this.preferences = preferences;
        this.systemConfigs = systemConfigs;
        this.titleKey = '';
        this.multiSelect = false;
        this.multiSelectButtonLabel = 'LBL_SAVE';
        this.adapter = null;
        this.filterAdapter = null;
        this.subs = [];
        this.store = this.storeFactory.create();
    }
    ngOnInit() {
        this.closeButton = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.activeModal.close({
                    type: 'close-button'
                });
            }
        };
        this.init();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    init() {
        if (!this.module) {
            return;
        }
        this.initStore();
        this.initTableAdapter();
        this.initFilterAdapters();
    }
    getMaxColumns() {
        return this.maxColumnCalculator.getMaxColumns(of(true));
    }
    linkSelectedRecords() {
        this.activeModal.close({
            selection: this.store.recordList.selection,
            records: this.store.recordList.records
        });
    }
    buildSelectButton() {
        return {
            klass: ['btn', 'btn-primary', 'btn-sm'],
            onClick: () => {
                this.linkSelectedRecords();
            },
            labelKey: this.multiSelectButtonLabel
        };
    }
    initTableAdapter() {
        if (this.adapter === null) {
            this.adapter = new ModalRecordListTableAdapter(this.systemConfigs, this.preferences);
        }
        this.tableConfig = this.adapter.getTable(this.store, this.multiSelect);
        if (this.store?.listMetadata?.maxHeight) {
            this.tableConfig.maxListHeight = this.store.listMetadata.maxHeight;
        }
        if (!this.tableConfig?.maxListHeight) {
            const ui = this.systemConfigs.getConfigValue('ui') ?? {};
            const configModalHeight = this.systemConfigs.getConfigValue('record_modal_max_height') ?? '';
            this.tableConfig.maxListHeight = ui.record_modal_max_height ?? configModalHeight;
        }
        this.tableConfig.maxColumns$ = this.getMaxColumns();
    }
    initFilterAdapters() {
        if (this.filterAdapter === null) {
            this.filterAdapter = new ModalRecordFilterAdapter();
        }
        this.filterConfig = this.filterAdapter.getConfig(this.store);
    }
    initStore() {
        this.store.init(this.module, this.parentModule ?? '');
        this.loading$ = this.store.metadataLoading$;
        this.subs.push(this.store.linkClicked$.pipe(distinctUntilChanged(), skip(1)).subscribe(clicked => {
            if (!clicked) {
                return;
            }
            this.linkSelectedRecords();
        }));
    }
    static { this.ɵfac = function RecordListModalComponent_Factory(t) { return new (t || RecordListModalComponent)(i0.ɵɵdirectiveInject(i3$1.NgbActiveModal), i0.ɵɵdirectiveInject(RecordListModalStoreFactory), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(MaxColumnsCalculator), i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordListModalComponent, selectors: [["scrm-record-list-modal"]], inputs: { titleKey: "titleKey", module: "module", parentModule: "parentModule", multiSelect: "multiSelect", multiSelectButtonLabel: "multiSelectButtonLabel", adapter: "adapter", filterAdapter: "filterAdapter" }, features: [i0.ɵɵProvidersFeature([MaxColumnsCalculator])], decls: 4, vars: 5, consts: [["bodyKlass", "m-0 small-font", "footerKlass", "border-0", "headerKlass", "border-0", "klass", "record-list-modal", 3, "closable", "close", "title"], ["modal-body", ""], [4, "ngIf"], ["labelKey", "LBL_CONFIG_NO_CONFIG"], [1, "container-fluid"], [1, "row", "pb-3"], [1, "col"], [3, "config", 4, "ngIf"], [1, "row"], [3, "config"], [3, "overlay", 4, "ngIf"], [3, "overlay"]], template: function RecordListModalComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-modal", 0)(1, "div", 1);
            i0.ɵɵtemplate(2, RecordListModalComponent_ng_container_2_Template, 2, 0, "ng-container", 2);
            i0.ɵɵtemplate(3, RecordListModalComponent_ng_container_3_Template, 12, 6, "ng-container", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("closable", true)("close", ctx.closeButton)("title", ctx.titleKey);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", !ctx.tableConfig);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.tableConfig);
        } }, encapsulation: 2, data: { animation: [
                trigger('modalFade', [
                    transition('void <=> *', [
                        animate('800ms')
                    ]),
                ]),
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListModalComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-list-modal', providers: [MaxColumnsCalculator], animations: [
                    trigger('modalFade', [
                        transition('void <=> *', [
                            animate('800ms')
                        ]),
                    ]),
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-modal [closable]=\"true\"\n            [close]=\"closeButton\"\n            [title]=\"titleKey\"\n            bodyKlass=\"m-0 small-font\"\n            footerKlass=\"border-0\"\n            headerKlass=\"border-0\"\n            klass=\"record-list-modal\">\n\n    <div modal-body>\n\n        <ng-container *ngIf=\"!tableConfig\">\n            <scrm-label labelKey=\"LBL_CONFIG_NO_CONFIG\"></scrm-label>\n        </ng-container>\n\n        <ng-container *ngIf=\"tableConfig\">\n            <div>\n                <div class=\"container-fluid\">\n                    <div class=\"row pb-3\">\n                        <div class=\"col\">\n                            <scrm-list-filter *ngIf=\"filterConfig\" [config]=\"filterConfig\"></scrm-list-filter>\n                        </div>\n                    </div>\n                    <div class=\"row\">\n                        <div class=\"col\">\n                            <scrm-table [config]=\"tableConfig\">\n                            </scrm-table>\n                        </div>\n                    </div>\n                </div>\n\n                <ng-container *ngIf=\"(loading$ | async) as loading\">\n                    <scrm-loading-spinner *ngIf=\"loading\" [overlay]=\"true\"></scrm-loading-spinner>\n                </ng-container>\n            </div>\n            <ng-container *ngIf=\"multiSelect\">\n                    <scrm-button [config]=\"buildSelectButton()\"></scrm-button>\n            </ng-container>\n        </ng-container>\n    </div>\n</scrm-modal>\n" }]
    }], function () { return [{ type: i3$1.NgbActiveModal }, { type: RecordListModalStoreFactory }, { type: LanguageStore }, { type: MaxColumnsCalculator }, { type: UserPreferenceStore }, { type: SystemConfigStore }]; }, { titleKey: [{
            type: Input
        }], module: [{
            type: Input
        }], parentModule: [{
            type: Input
        }], multiSelect: [{
            type: Input
        }], multiSelectButtonLabel: [{
            type: Input
        }], adapter: [{
            type: Input
        }], filterAdapter: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RelateService {
    constructor(recordListStoreFactory) {
        this.recordList = recordListStoreFactory.create();
    }
    init(module) {
        this.recordList.init(module, false);
    }
    search(term, field) {
        const criteria = this.recordList.criteria;
        criteria.filters[field] = {
            field,
            operator: '=',
            values: [term]
        };
        this.recordList.updateSearchCriteria(criteria, false);
        return this.recordList.load(false).pipe(map(value => value.records), take(1), shareReplay(1));
    }
    static { this.ɵfac = function RelateService_Factory(t) { return new (t || RelateService)(i0.ɵɵinject(RecordListStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RelateService, factory: RelateService.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateService, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseRelateComponent extends BaseFieldComponent {
    constructor(languages, typeFormatter, relateService, moduleNameMapper, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.relateService = relateService;
        this.moduleNameMapper = moduleNameMapper;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.selectedValues = [];
        this.options = [];
        this.status = '';
        this.initModule = '';
        this.search = (text) => {
            if (text === '') {
                return of([]);
            }
            this.status = 'searching';
            return this.relateService.search(text, this.getRelateFieldName()).pipe(tap(() => this.status = 'found'), catchError(() => {
                this.status = 'error';
                return of([]);
            }), map(records => {
                if (!records || records.length < 1) {
                    this.status = 'not-found';
                    return [];
                }
                const flatRecords = [];
                records.forEach((record) => {
                    if (record && record.attributes) {
                        flatRecords.push(record.attributes);
                    }
                });
                this.status = '';
                return flatRecords;
            }));
        };
    }
    get module() {
        if (!this.record || !this.record.module) {
            return null;
        }
        return this.record.module;
    }
    ngOnInit() {
        super.ngOnInit();
        this.init();
        this.subs.push(this.field.valueChanges$.subscribe(() => {
            this.onModuleChange();
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    onModuleChange() {
        const currentModule = this.initModule;
        const newModule = this?.field?.definition?.module ?? '';
        if (currentModule === newModule) {
            return;
        }
        this.initModule = newModule;
        if (currentModule === '' && currentModule !== newModule) {
            this.init();
        }
        if (newModule === '') {
            this.status = 'no-module';
        }
        else {
            this.init();
            this.status = '';
            this.selectedValues = [];
            this.options = [];
        }
    }
    getRelateFieldName() {
        if (!this.field?.definition?.metadata?.relateSearchField) {
            return (this.field && this.field.definition && this.field.definition.rname) || 'name';
        }
        return this.field.definition.metadata.relateSearchField;
    }
    getRelateIdField() {
        return (this.field && this.field.definition && this.field.definition.id_name) || '';
    }
    getRelatedModule() {
        const legacyName = (this.field && this.field.definition && this.field.definition.module) || '';
        if (!legacyName) {
            return '';
        }
        return this.moduleNameMapper.toFrontend(legacyName);
    }
    getMessage() {
        const messages = {
            searching: 'LBL_SEARCHING',
            'not-found': 'LBL_NOT_FOUND',
            error: 'LBL_SEARCH_ERROR',
            found: 'LBL_FOUND',
            'no-module': 'LBL_NO_MODULE_SELECTED'
        };
        if (messages[this.status]) {
            return messages[this.status];
        }
        return '';
    }
    getInvalidClass() {
        if (this.validateOnlyOnSubmit ? this.isInvalid() : (this.field.formControl.invalid && this.field.formControl.touched)) {
            return 'is-invalid';
        }
        if (this.hasSearchError()) {
            return 'is-invalid';
        }
        return '';
    }
    hasSearchError() {
        return this.status === 'error' || this.status === 'not-found';
    }
    resetStatus() {
        this.status = '';
    }
    getPlaceholderLabel() {
        return this.languages.getAppString('LBL_TYPE_TO_SEARCH') || '';
    }
    init() {
        this.initModule = this?.field?.definition?.module ?? '';
        if (this.relateService) {
            this.relateService.init(this.getRelatedModule());
        }
    }
    buildRelate(id, relateValue) {
        const relate = { id };
        if (this.getRelateFieldName()) {
            relate[this.getRelateFieldName()] = relateValue;
        }
        return relate;
    }
    static { this.ɵfac = function BaseRelateComponent_Factory(t) { return new (t || BaseRelateComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(RelateService), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseRelateComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseRelateComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseRelateComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: RelateService }, { type: ModuleNameMapper }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$E = ["tag"];
const _c1$d = ["dropdownFilterInput"];
function RelateEditFieldComponent_ng_container_1_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 8);
} }
function RelateEditFieldComponent_ng_container_1_ng_template_5_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵlistener("click", function RelateEditFieldComponent_ng_container_1_ng_template_5_Template_div_click_0_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementStart(1, "input", 10, 11);
    i0.ɵɵlistener("ngModelChange", function RelateEditFieldComponent_ng_container_1_ng_template_5_Template_input_ngModelChange_1_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r7 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r7.filterValue = $event); })("keyup", function RelateEditFieldComponent_ng_container_1_ng_template_5_Template_input_keyup_1_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.onFilterInput($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelement(3, "scrm-image", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngModel", ctx_r3.filterValue);
} }
function RelateEditFieldComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 2)(2, "p-dropdown", 3, 4);
    i0.ɵɵlistener("ngModelChange", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_ngModelChange_2_listener($event) { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r10.selectedValue = $event); })("onChange", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_onChange_2_listener($event) { i0.ɵɵrestoreView(_r11); const ctx_r12 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r12.onAdd($event.value)); })("onLazyLoad", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_onLazyLoad_2_listener() { i0.ɵɵrestoreView(_r11); const ctx_r13 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r13.onFilter()); })("onShow", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_onShow_2_listener() { i0.ɵɵrestoreView(_r11); const ctx_r14 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r14.focusFilterInput()); })("onHide", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_onHide_2_listener() { i0.ɵɵrestoreView(_r11); const _r1 = i0.ɵɵreference(3); const ctx_r15 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r15.resetFunction(_r1.options)); })("onClear", function RelateEditFieldComponent_ng_container_1_Template_p_dropdown_onClear_2_listener($event) { i0.ɵɵrestoreView(_r11); const ctx_r16 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r16.onClear($event)); });
    i0.ɵɵtemplate(4, RelateEditFieldComponent_ng_container_1_ng_template_4_Template, 1, 0, "ng-template", 5);
    i0.ɵɵtemplate(5, RelateEditFieldComponent_ng_container_1_ng_template_5_Template, 4, 1, "ng-template", 6);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div");
    i0.ɵɵelement(7, "scrm-button", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("options", ctx_r0.options)("ngModel", ctx_r0.selectedValue)("optionLabel", ctx_r0.getRelateFieldName())("emptyMessage", ctx_r0.emptyFilterLabel)("emptyFilterMessage", ctx_r0.emptyFilterLabel)("placeholder", ctx_r0.placeholderLabel)("autoOptionFocus", false)("autofocusFilter", false)("focusOnHover", true)("filter", true)("lazy", true)("dataKey", "id")("filterBy", ctx_r0.getRelateFieldName())("showClear", true)("styleClass", "w-100 " + ctx_r0.getInvalidClass());
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("config", ctx_r0.selectButton);
} }
class RelateEditFieldComponent extends BaseRelateComponent {
    /**
     * Constructor
     *
     * @param {object} languages service
     * @param {object} typeFormatter service
     * @param {object} relateService service
     * @param {object} moduleNameMapper service
     * @param {object} modalService service
     * @param {object} logic
     * @param {object} logicDisplay
     */
    constructor(languages, typeFormatter, relateService, moduleNameMapper, modalService, logic, logicDisplay) {
        super(languages, typeFormatter, relateService, moduleNameMapper, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.relateService = relateService;
        this.moduleNameMapper = moduleNameMapper;
        this.modalService = modalService;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.selectedValue = {};
        this.placeholderLabel = '';
        this.emptyFilterLabel = '';
        this.filterValue = '';
    }
    /**
     * On init handler
     */
    ngOnInit() {
        super.ngOnInit();
        this.init();
        this.getTranslatedLabels();
        this.selectButton = {
            klass: ['btn', 'btn-sm', 'btn-outline-secondary', 'm-0', 'border-0'],
            onClick: () => {
                this.showSelectModal();
            },
            icon: 'cursor'
        };
    }
    init() {
        super.init();
        this.initValue();
        const idFieldName = this.getRelateIdField();
        if (idFieldName && this.record && this.record.fields && this.record.fields[idFieldName]) {
            this.idField = this.record.fields[idFieldName];
        }
    }
    initValue() {
        if (!this.field.valueObject) {
            this.selectedValue = {};
            this.field.formControl.setValue('');
            return;
        }
        if (!this.field.valueObject.id) {
            this.selectedValue = {};
            this.field.formControl.setValue('');
            return;
        }
        if (this.field?.metadata?.relateSearchField) {
            const rname = this.field?.definition?.rname ?? 'name';
            this.field.valueObject[this.field.metadata.relateSearchField] = this.field.valueObject[rname];
        }
        this.selectedValue = this.field.valueObject;
        this.options = [this.field.valueObject];
    }
    /**
     * Handle newly added item
     *
     * @param {object} item added
     */
    onAdd(item) {
        if (item) {
            const relateName = this.getRelateFieldName();
            this.setValue(item.id, item[relateName]);
            return;
        }
        this.setValue('', '');
        this.selectedValue = {};
        return;
    }
    /**
     * Handle item removal
     */
    onRemove() {
        this.setValue('', '');
        this.selectedValue = {};
        this.options = [];
    }
    onClear(event) {
        this.selectedValue = {};
        this.filterValue = '';
        this.options = [];
        this.onRemove();
    }
    onFilter() {
        const relateName = this.getRelateFieldName();
        this.filterValue = this.filterValue ?? '';
        const matches = this.filterValue.match(/^\s*$/g);
        if (matches && matches.length) {
            this.filterValue = '';
        }
        let term = this.filterValue;
        this.search(term).pipe(take(1), map(data => data.filter(item => item[relateName] !== '')), map(filteredData => filteredData.map(item => ({
            id: item.id,
            [relateName]: item[relateName]
        })))).subscribe(filteredOptions => {
            this.options = filteredOptions;
            if (!this?.selectedValue || !this?.selectedValue?.id) {
                return;
            }
            let found = false;
            filteredOptions.some(value => {
                if (value?.id === this.selectedValue.id) {
                    found = true;
                    return true;
                }
                return false;
            });
            if (found === false && this.selectedValue) {
                this.options.push(this.selectedValue);
            }
        });
    }
    resetFunction(options) {
        this.filterValue = '';
        this.options = [];
        if (!emptyObject(this.selectedValue)) {
            this.options = [this.selectedValue];
        }
    }
    onFilterInput(event) {
        event.stopPropagation();
        this.tag.onLazyLoad.emit();
    }
    /**
     * Set value on field
     *
     * @param {string} id to set
     * @param {string} relateValue to set
     */
    setValue(id, relateValue) {
        const relate = this.buildRelate(id, relateValue);
        this.field.value = relateValue;
        this.field.valueObject = relate;
        this.field.formControl.setValue(relateValue);
        this.field.formControl.markAsDirty();
        if (this.idField) {
            this.idField.value = id;
            this.idField.formControl.setValue(id);
            this.idField.formControl.markAsDirty();
        }
        if (relateValue) {
            const relateName = this.getRelateFieldName();
            this.selectedValue = { id: id, [relateName]: relateValue };
        }
        this.options = [this.selectedValue];
    }
    /**
     * Show record selection modal
     */
    showSelectModal() {
        const modal = this.modalService.open(RecordListModalComponent, { size: 'xl', scrollable: true });
        modal.componentInstance.module = this.getRelatedModule();
        modal.result.then((data) => {
            if (!data || !data.selection || !data.selection.selected) {
                return;
            }
            const record = this.getSelectedRecord(data);
            this.setItem(record);
        });
    }
    /**
     * Get Selected Record
     *
     * @param {object} data RecordListModalResult
     * @returns {object} Record
     */
    getSelectedRecord(data) {
        let id = '';
        Object.keys(data.selection.selected).some(selected => {
            id = selected;
            return true;
        });
        let record = null;
        data.records.some(rec => {
            if (rec && rec.id === id) {
                record = rec;
                return true;
            }
        });
        return record;
    }
    /**
     * Set the record as the selected item
     *
     * @param {object} record to set
     */
    setItem(record) {
        this.tag.writeValue(record.attributes);
        this.onAdd(record.attributes);
    }
    getTranslatedLabels() {
        this.placeholderLabel = this.languages.getAppString('LBL_SELECT_ITEM') || '';
        this.emptyFilterLabel = this.languages.getAppString('ERR_SEARCH_NO_RESULTS') || '';
    }
    focusFilterInput() {
        this.dropdownFilterInput.nativeElement.focus();
    }
    static { this.ɵfac = function RelateEditFieldComponent_Factory(t) { return new (t || RelateEditFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(RelateService), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(i3$1.NgbModal), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RelateEditFieldComponent, selectors: [["scrm-relate-edit"]], viewQuery: function RelateEditFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$E, 5);
            i0.ɵɵviewQuery(_c1$d, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tag = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dropdownFilterInput = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([RelateService]), i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[1, "d-flex", "align-items-center"], [4, "ngIf"], [1, "flex-grow-1", "w-100", "mr-1"], [3, "options", "ngModel", "optionLabel", "emptyMessage", "emptyFilterMessage", "placeholder", "autoOptionFocus", "autofocusFilter", "focusOnHover", "filter", "lazy", "dataKey", "filterBy", "showClear", "styleClass", "ngModelChange", "onChange", "onLazyLoad", "onShow", "onHide", "onClear"], ["tag", ""], ["pTemplate", "dropdownicon"], ["pTemplate", "filter"], [3, "config"], ["image", "down_carret"], [1, "p-dropdown-filter-container", 3, "click"], ["type", "text", "pInputText", "", "autocomplete", "off", "tabindex", "0", 1, "p-dropdown-filter", "p-component", 3, "ngModel", "ngModelChange", "keyup"], ["dropdownFilterInput", ""], ["image", "search", 1, "p-element", "p-dropdown-filter-search-icon"]], template: function RelateEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, RelateEditFieldComponent_ng_container_1_Template, 8, 16, "ng-container", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.initModule);
        } }, dependencies: [i2.NgIf, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgModel, ButtonComponent, i7.PrimeTemplate, ImageComponent, i13.Dropdown, i14.InputText], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-relate-edit', providers: [RelateService], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"d-flex align-items-center\">\n    <ng-container *ngIf=\"initModule\">\n        <div class=\"flex-grow-1 w-100 mr-1\">\n            <p-dropdown\n                #tag\n                [options]=\"options\"\n                [(ngModel)]=\"selectedValue\"\n                [optionLabel]=\"getRelateFieldName()\"\n                (onChange)=\"onAdd($event.value)\"\n                (onLazyLoad)=\"onFilter()\"\n                (onShow)=\"focusFilterInput()\"\n                (onHide)=\"resetFunction(tag.options)\"\n                [emptyMessage]=\"emptyFilterLabel\"\n                [emptyFilterMessage]=\"emptyFilterLabel\"\n                [placeholder]=\"placeholderLabel\"\n                [autoOptionFocus]=\"false\"\n                [autofocusFilter]=\"false\"\n                [focusOnHover] = \"true\"\n                [filter]=\"true\"\n                [lazy]=\"true\"\n                [dataKey]=\"'id'\"\n                [filterBy]=\"getRelateFieldName()\"\n                [showClear]=\"true\"\n                (onClear)=\"onClear($event)\"\n                [styleClass]=\"'w-100 ' + getInvalidClass()\"\n            >\n                <ng-template pTemplate=\"dropdownicon\">\n                    <scrm-image image=\"down_carret\"></scrm-image>\n                </ng-template>\n                <ng-template pTemplate=\"filter\" let-options=\"options\">\n\n                    <div class=\"p-dropdown-filter-container\" (click)=\"$event.stopPropagation()\">\n                        <input #dropdownFilterInput\n                               type=\"text\"\n                               pInputText\n                               autocomplete=\"off\"\n                               class=\"p-dropdown-filter p-component\"\n                               [(ngModel)]=\"filterValue\"\n                               (keyup)=\"onFilterInput($event)\"\n                               tabindex=\"0\">\n                        <scrm-image image=\"search\" class=\"p-element p-dropdown-filter-search-icon\"></scrm-image>\n                    </div>\n\n                </ng-template>\n            </p-dropdown>\n        </div>\n        <div>\n            <scrm-button [config]=\"selectButton\">\n            </scrm-button>\n        </div>\n    </ng-container>\n</div>\n\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: RelateService }, { type: ModuleNameMapper }, { type: i3$1.NgbModal }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { tag: [{
            type: ViewChild,
            args: ['tag']
        }], dropdownFilterInput: [{
            type: ViewChild,
            args: ['dropdownFilterInput']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RelateEditFieldModule {
    static { this.ɵfac = function RelateEditFieldModule_Factory(t) { return new (t || RelateEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RelateEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule,
            FormsModule,
            ButtonModule,
            MultiSelectModule,
            ImageModule,
            DropdownModule,
            InputTextModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [RelateEditFieldComponent],
                exports: [RelateEditFieldComponent],
                imports: [
                    CommonModule,
                    LabelModule,
                    FormsModule,
                    ButtonModule,
                    MultiSelectModule,
                    ImageModule,
                    DropdownModule,
                    InputTextModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RelateEditFieldModule, { declarations: [RelateEditFieldComponent], imports: [CommonModule,
        LabelModule,
        FormsModule,
        ButtonModule,
        MultiSelectModule,
        ImageModule,
        DropdownModule,
        InputTextModule], exports: [RelateEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$D = ["tag"];
const _c1$c = ["dropdownFilterInput"];
function RelateFilterFieldComponent_ng_container_1_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 9);
} }
function RelateFilterFieldComponent_ng_container_1_ng_template_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 10);
} }
function RelateFilterFieldComponent_ng_container_1_ng_template_6_scrm_image_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 10);
} }
function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵlistener("click", function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template_div_click_0_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementStart(1, "div", 12);
    i0.ɵɵelement(2, "input", 13);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 14);
    i0.ɵɵlistener("click", function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template_div_click_3_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.onSelectAll()); });
    i0.ɵɵtemplate(4, RelateFilterFieldComponent_ng_container_1_ng_template_6_scrm_image_4_Template, 1, 0, "scrm-image", 15);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(5, "div", 16);
    i0.ɵɵlistener("click", function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template_div_click_5_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementStart(6, "input", 17, 18);
    i0.ɵɵlistener("ngModelChange", function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template_input_ngModelChange_6_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r12 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r12.filterValue = $event); })("keyup", function RelateFilterFieldComponent_ng_container_1_ng_template_6_Template_input_keyup_6_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r13 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r13.onFilterInput($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "span", 19);
    i0.ɵɵelement(9, "scrm-image", 20);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", ctx_r4.selectAll);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngModel", ctx_r4.filterValue);
} }
function RelateFilterFieldComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 2)(2, "p-multiSelect", 3, 4);
    i0.ɵɵlistener("ngModelChange", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_ngModelChange_2_listener($event) { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r14.selectedValues = $event); })("onChange", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onChange_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r16 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r16.onAdd()); })("onLazyLoad", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onLazyLoad_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r17 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r17.onFilter()); })("onRemove", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onRemove_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r18 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r18.onRemove()); })("onPanelShow", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onPanelShow_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r19 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r19.onPanelShow()); })("onPanelHide", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onPanelHide_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r20 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r20.resetFunction()); })("onClear", function RelateFilterFieldComponent_ng_container_1_Template_p_multiSelect_onClear_2_listener() { i0.ɵɵrestoreView(_r15); const ctx_r21 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r21.onClear()); });
    i0.ɵɵtemplate(4, RelateFilterFieldComponent_ng_container_1_ng_template_4_Template, 1, 0, "ng-template", 5);
    i0.ɵɵtemplate(5, RelateFilterFieldComponent_ng_container_1_ng_template_5_Template, 1, 0, "ng-template", 6);
    i0.ɵɵtemplate(6, RelateFilterFieldComponent_ng_container_1_ng_template_6_Template, 10, 2, "ng-template", 7);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(7, "div");
    i0.ɵɵelement(8, "scrm-button", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("options", ctx_r0.options)("ngModel", ctx_r0.selectedValues)("optionLabel", ctx_r0.getRelateFieldName())("placeholder", ctx_r0.placeholderLabel)("selectedItemsLabel", "{0} " + ctx_r0.selectedItemsLabel)("emptyFilterMessage", ctx_r0.emptyFilterLabel)("emptyMessage", ctx_r0.emptyFilterLabel)("maxSelectedLabels", ctx_r0.maxSelectedLabels)("styleClass", "w-100 " + ctx_r0.getInvalidClass())("showToggleAll", true)("selectAll", ctx_r0.selectAll)("autoOptionFocus", false)("autofocusFilter", false)("focusOnHover", true)("showClear", true)("filter", true)("lazy", true)("dataKey", "id")("filterBy", ctx_r0.getRelateFieldName());
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("config", ctx_r0.selectButton);
} }
class RelateFilterFieldComponent extends BaseRelateComponent {
    /**
     * Constructor
     *
     * @param {object} languages service
     * @param {object} typeFormatter service
     * @param {object} relateService service
     * @param {object} moduleNameMapper service
     * @param {object} modalService service
     * @param {object} logic
     * @param {object} logicDisplay
     */
    constructor(languages, typeFormatter, relateService, moduleNameMapper, modalService, logic, logicDisplay) {
        super(languages, typeFormatter, relateService, moduleNameMapper, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.relateService = relateService;
        this.moduleNameMapper = moduleNameMapper;
        this.modalService = modalService;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.placeholderLabel = '';
        this.selectedItemsLabel = '';
        this.emptyFilterLabel = '';
        this.maxSelectedLabels = 20;
        this.selectAll = false;
        this.filterValue = '';
        this.selectButton = {
            klass: ['btn', 'btn-sm', 'btn-outline-secondary', 'm-0', 'border-0'],
            onClick: () => {
                this.showSelectModal();
            },
            icon: 'cursor'
        };
    }
    /**
     * On init handler
     */
    ngOnInit() {
        this.selectAll = false;
        const filter = this.record;
        this.field.valueList = [];
        this.field.valueObjectArray = [];
        let values = (this.field && this.field.criteria && this.field.criteria.values) || [];
        values = values.filter(value => !value);
        if (values.length > 0) {
            this.field.valueList = values;
        }
        let valueObjectArray = (this.field && this.field.criteria && this.field.criteria.valueObjectArray) || [];
        valueObjectArray = valueObjectArray.map(value => {
            const mapped = { ...value };
            mapped[this.getRelateFieldName()] = value[this.getRelateFieldName()] ?? value?.name ?? '';
            return mapped;
        });
        if (valueObjectArray.length > 0) {
            this.field.valueObjectArray = deepClone(valueObjectArray);
            this.selectedValues = deepClone(valueObjectArray);
        }
        super.ngOnInit();
        this.options = this.options ?? [];
        this.getTranslatedLabels();
        this.addCurrentlySelectedToOptions(this.options ?? []);
        const idFieldName = this.getRelateIdField();
        if (idFieldName && filter && filter.criteriaFields && filter.criteriaFields[idFieldName]) {
            this.idField = filter.criteriaFields[idFieldName];
            this.idField.valueList = [];
            let idValues = (this.idField && this.idField.criteria && this.idField.criteria.values) || [];
            idValues = idValues.filter(value => !!value);
            if (idValues.length > 0) {
                this.idField.valueList = deepClone(idValues);
            }
        }
    }
    /**
     * Handle newly added item
     */
    onAdd() {
        this.updateFieldValues();
        this.calculateSelectAll();
    }
    /**
     * Handle item removal
     */
    onRemove() {
        this.updateFieldValues();
        this.calculateSelectAll();
    }
    onClear() {
        this.options = [];
        this.selectedValues = [];
        this.selectAll = false;
        this.filterValue = '';
        this.onRemove();
    }
    onSelectAll() {
        this.selectAll = !this.selectAll;
        if (this.selectAll) {
            if (this.tag.visibleOptions() && this.tag.visibleOptions().length) {
                this.selectedValues = this.tag.visibleOptions();
            }
            else {
                this.selectedValues = this.options;
            }
            this.onAdd();
        }
        else {
            this.selectedValues = [];
            this.onRemove();
        }
    }
    getTranslatedLabels() {
        this.placeholderLabel = this.languages.getAppString('LBL_SELECT_ITEM') || '';
        this.selectedItemsLabel = this.languages.getAppString('LBL_ITEMS_SELECTED') || '';
        this.emptyFilterLabel = this.languages.getAppString('ERR_SEARCH_NO_RESULTS') || '';
    }
    onPanelShow() {
        this.dropdownFilterInput.nativeElement.focus();
        this.calculateSelectAll();
    }
    resetFunction() {
        this.filterValue = '';
        this.options = this.selectedValues;
    }
    onFilterInput(event) {
        event?.stopPropagation();
        this.selectAll = false;
        this.tag.onLazyLoad.emit();
    }
    onFilter() {
        const relateName = this.getRelateFieldName();
        this.filterValue = this.filterValue ?? '';
        const matches = this.filterValue.match(/^\s*$/g);
        if (matches && matches.length) {
            this.filterValue = '';
        }
        let term = this.filterValue;
        this.search(term).pipe(take(1), map(data => data.filter((item) => item[relateName] !== '')), map(filteredData => filteredData.map((item) => ({
            id: item.id,
            [relateName]: item[relateName]
        })))).subscribe(filteredOptions => {
            this.options = filteredOptions;
            this.addCurrentlySelectedToOptions(filteredOptions);
            this.calculateSelectAll();
        });
    }
    updateFieldValues() {
        let value = this?.selectedValues?.map(option => option[this.getRelateFieldName()]) ?? null;
        if (!value) {
            value = [];
        }
        this.field.valueList = value;
        this.field.valueObjectArray = deepClone(this.selectedValues ?? []);
        this.updateSearchCriteria(this.field);
        this.field.criteria.valueObjectArray = deepClone(this.field.valueObjectArray);
        this.updateIdField();
    }
    updateIdField() {
        if (!this.idField) {
            return;
        }
        this.idField.valueList = this?.selectedValues?.map(option => option.id) ?? [];
        this.updateSearchCriteria(this.idField);
    }
    /**
     * Set value on field
     *
     * @param item
     */
    setValue(item) {
        const relateName = this.getRelateFieldName();
        const id = item?.id ?? '';
        const relateValue = item[relateName];
        if (this.idField && this.idField.valueList.includes(id)) {
            return;
        }
        if (!this.idField && this.field.valueList.includes(relateValue)) {
            return;
        }
        const valueObject = {};
        valueObject.id = id;
        valueObject[relateName] = relateValue;
        this.field.valueObjectArray.push(valueObject);
        this.field.valueList.push(relateValue);
        if (this.idField) {
            this.idField.valueList.push(id);
            this.updateSearchCriteria(this.idField);
        }
        this.updateSearchCriteria(this.field);
        if (!this.field.criteria.valueObjectArray) {
            this.field.criteria.valueObjectArray = [];
        }
        this.field.criteria.valueObjectArray.push(valueObject);
    }
    /**
     * Set value on field criteria and form
     */
    updateSearchCriteria(field) {
        field.criteria.operator = '=';
        field.criteria.values = field.valueList;
        field.formControl.setValue(field.valueList);
        field.formControl.markAsDirty();
    }
    /**
     * Show record selection modal
     */
    showSelectModal() {
        const modal = this.modalService.open(RecordListModalComponent, { size: 'xl', scrollable: true });
        modal.componentInstance.module = this.getRelatedModule();
        modal.result.then((data) => {
            if (!data || !data.selection || !data.selection.selected) {
                return;
            }
            const record = this.getSelectedRecord(data);
            const found = this.field.valueObjectArray.find(element => element.id === record.id);
            if (found) {
                return;
            }
            this.setItem(record);
            this.tag.updateModel(this.selectedValues);
        });
    }
    /**
     * Get Selected Record
     *
     * @param {object} data RecordListModalResult
     * @returns {object} Record
     */
    getSelectedRecord(data) {
        let id = '';
        Object.keys(data.selection.selected).some(selected => {
            id = selected;
            return true;
        });
        let record = null;
        data.records.some(rec => {
            if (rec && rec.id === id) {
                record = rec;
                return true;
            }
        });
        return record;
    }
    /**
     * Set the record as the selected item
     *
     * @param {object} record to set
     */
    setItem(record) {
        const relateName = this.getRelateFieldName();
        const newItem = {
            id: record?.attributes?.id,
            [relateName]: record?.attributes[relateName]
        };
        const inList = this.isInList(this.selectedValues, newItem);
        if (inList) {
            return;
        }
        this.selectedValues.push(newItem);
        this.addCurrentlySelectedToOptions(this.options);
        this.onAdd();
    }
    addCurrentlySelectedToOptions(filteredOptions) {
        if (!this?.selectedValues || !this?.selectedValues.length) {
            return;
        }
        this.selectedValues.forEach(selectedValue => {
            let found = this.isInList(filteredOptions, selectedValue);
            if (found === false && selectedValue) {
                this.options.push(selectedValue);
            }
        });
    }
    isInList(filteredOptions, selectedValue) {
        let found = false;
        filteredOptions.some((value) => {
            if (value?.id === selectedValue?.id) {
                found = true;
                return true;
            }
            return false;
        });
        return found;
    }
    calculateSelectAll() {
        const visibleOptions = this?.tag?.visibleOptions() ?? [];
        const selectedValuesKeys = (this?.selectedValues ?? []).map(item => item.value);
        if (!visibleOptions.length || !selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        if (visibleOptions.length > selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        this.selectAll = visibleOptions.every(item => selectedValuesKeys.includes(item.value));
    }
    static { this.ɵfac = function RelateFilterFieldComponent_Factory(t) { return new (t || RelateFilterFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(RelateService), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(i3$1.NgbModal), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RelateFilterFieldComponent, selectors: [["scrm-relate-filter"]], viewQuery: function RelateFilterFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$D, 5);
            i0.ɵɵviewQuery(_c1$c, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tag = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dropdownFilterInput = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([RelateService]), i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[1, "d-flex", "align-items-center"], [4, "ngIf"], [1, "flex-grow-1", "w-100", "mr-1"], [3, "options", "ngModel", "optionLabel", "placeholder", "selectedItemsLabel", "emptyFilterMessage", "emptyMessage", "maxSelectedLabels", "styleClass", "showToggleAll", "selectAll", "autoOptionFocus", "autofocusFilter", "focusOnHover", "showClear", "filter", "lazy", "dataKey", "filterBy", "ngModelChange", "onChange", "onLazyLoad", "onRemove", "onPanelShow", "onPanelHide", "onClear"], ["tag", ""], ["pTemplate", "dropdownicon"], ["pTemplate", "checkicon"], ["pTemplate", "filter"], [3, "config"], ["image", "down_carret"], ["image", "checkbox_cross"], [1, "p-checkbox", "p-component", 3, "click"], ["data-p-hidden-accessible", "true", 1, "p-hidden-accessible"], ["type", "checkbox", "checked", "false", "aria-label", "All items unselected"], ["role", "checkbox", "aria-checked", "false", 1, "p-checkbox-box", 3, "click"], ["image", "checkbox_cross", 4, "ngIf"], [1, "p-multiselect-filter-container", 3, "click"], ["type", "text", "pInputText", "", "autocomplete", "off", "tabindex", "0", 1, "p-multiselect-filter", "p-inputtext", "p-component", 3, "ngModel", "ngModelChange", "keyup"], ["dropdownFilterInput", ""], [1, "p-multiselect-filter-icon"], ["image", "search", 1, "p-element", "p-dropdown-filter-search-icon"]], template: function RelateFilterFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, RelateFilterFieldComponent_ng_container_1_Template, 9, 20, "ng-container", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.initModule);
        } }, dependencies: [i2.NgIf, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgModel, ButtonComponent, ImageComponent, i10.MultiSelect, i7.PrimeTemplate, i14.InputText], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateFilterFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-relate-filter', providers: [RelateService], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"d-flex align-items-center\">\n    <ng-container *ngIf=\"initModule\">\n        <div class=\"flex-grow-1 w-100 mr-1\">\n            <p-multiSelect\n                #tag\n                [options]=\"this.options\"\n                [(ngModel)]=\"selectedValues\"\n                [optionLabel]=\"getRelateFieldName()\"\n                (onChange)=\"onAdd()\"\n                (onLazyLoad)=\"onFilter()\"\n                (onRemove)=\"onRemove()\"\n                (onPanelShow)=\"onPanelShow()\"\n                (onPanelHide)=\"resetFunction()\"\n                [placeholder]=\"placeholderLabel\"\n                [selectedItemsLabel]=\"'{0} ' + selectedItemsLabel\"\n                [emptyFilterMessage]=\"emptyFilterLabel\"\n                [emptyMessage]=\"emptyFilterLabel\"\n                [maxSelectedLabels]=\"maxSelectedLabels\"\n                [styleClass]=\"'w-100 ' + getInvalidClass()\"\n                [showToggleAll]=\"true\"\n                [selectAll]=\"selectAll\"\n                [autoOptionFocus]=\"false\"\n                [autofocusFilter]=\"false\"\n                [focusOnHover]=\"true\"\n                [showClear]=\"true\"\n                (onClear)=\"onClear()\"\n                [filter]=\"true\"\n                [lazy]=\"true\"\n                [dataKey]=\"'id'\"\n                [filterBy]=\"getRelateFieldName()\"\n            >\n                <ng-template pTemplate=\"dropdownicon\">\n                    <scrm-image image=\"down_carret\"></scrm-image>\n                </ng-template>\n                <ng-template pTemplate=\"checkicon\">\n                    <scrm-image image=\"checkbox_cross\"></scrm-image>\n                </ng-template>\n\n                <ng-template pTemplate=\"filter\" let-options=\"options\">\n\n                    <div class=\"p-checkbox p-component\" (click)=\"$event.stopPropagation()\">\n                        <div class=\"p-hidden-accessible\" data-p-hidden-accessible=\"true\">\n                            <input type=\"checkbox\" checked=\"false\" aria-label=\"All items unselected\">\n                        </div>\n                        <div role=\"checkbox\" class=\"p-checkbox-box\" aria-checked=\"false\" (click)=\"onSelectAll()\">\n                            <scrm-image image=\"checkbox_cross\" *ngIf=\"selectAll\"></scrm-image>\n                        </div>\n                    </div>\n                    <div class=\"p-multiselect-filter-container\" (click)=\"$event.stopPropagation()\">\n                        <input #dropdownFilterInput\n                               type=\"text\"\n                               pInputText\n                               autocomplete=\"off\"\n                               class=\"p-multiselect-filter p-inputtext p-component\"\n                               [(ngModel)]=\"filterValue\"\n                               (keyup)=\"onFilterInput($event);\"\n                               tabindex=\"0\">\n                        <span class=\"p-multiselect-filter-icon\">\n                            <scrm-image image=\"search\" class=\"p-element p-dropdown-filter-search-icon\"></scrm-image>\n                        </span>\n                    </div>\n\n                </ng-template>\n\n\n\n            </p-multiSelect>\n        </div>\n        <div>\n            <scrm-button [config]=\"selectButton\">\n            </scrm-button>\n        </div>\n    </ng-container>\n</div>\n\n\n\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: RelateService }, { type: ModuleNameMapper }, { type: i3$1.NgbModal }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, { tag: [{
            type: ViewChild,
            args: ['tag']
        }], dropdownFilterInput: [{
            type: ViewChild,
            args: ['dropdownFilterInput']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TextDetailFieldModule {
    static { this.ɵfac = function TextDetailFieldModule_Factory(t) { return new (t || TextDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TextDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [TextDetailFieldComponent],
                exports: [TextDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TextDetailFieldModule, { declarations: [TextDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [TextDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PhoneDetailFieldModule {
    static { this.ɵfac = function PhoneDetailFieldModule_Factory(t) { return new (t || PhoneDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PhoneDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PhoneDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [PhoneDetailFieldComponent],
                exports: [PhoneDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PhoneDetailFieldModule, { declarations: [PhoneDetailFieldComponent], imports: [CommonModule], exports: [PhoneDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateEditFieldModule {
    static { this.ɵfac = function DateEditFieldModule_Factory(t) { return new (t || DateEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            NgbDatepickerModule,
            ButtonModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateEditFieldComponent],
                exports: [DateEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    NgbDatepickerModule,
                    ButtonModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateEditFieldModule, { declarations: [DateEditFieldComponent], imports: [CommonModule,
        FormsModule,
        NgbDatepickerModule,
        ButtonModule,
        ReactiveFormsModule], exports: [DateEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MultiEnumFilterFieldModule {
    static { this.ɵfac = function MultiEnumFilterFieldModule_Factory(t) { return new (t || MultiEnumFilterFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MultiEnumFilterFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule,
            TagInputModule,
            ImageModule,
            MultiSelectModule,
            SharedModule,
            ButtonModule,
            InputTextModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumFilterFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [MultiEnumFilterFieldComponent],
                exports: [MultiEnumFilterFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule,
                    TagInputModule,
                    ImageModule,
                    MultiSelectModule,
                    SharedModule,
                    ButtonModule,
                    InputTextModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MultiEnumFilterFieldModule, { declarations: [MultiEnumFilterFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        TagInputModule,
        ImageModule,
        MultiSelectModule,
        SharedModule,
        ButtonModule,
        InputTextModule], exports: [MultiEnumFilterFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RelateDetailFieldsModule {
    static { this.ɵfac = function RelateDetailFieldsModule_Factory(t) { return new (t || RelateDetailFieldsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RelateDetailFieldsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateDetailFieldsModule, [{
        type: NgModule,
        args: [{
                declarations: [RelateDetailFieldComponent],
                exports: [RelateDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RelateDetailFieldsModule, { declarations: [RelateDetailFieldComponent], imports: [CommonModule], exports: [RelateDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RelateFilterFieldModule {
    static { this.ɵfac = function RelateFilterFieldModule_Factory(t) { return new (t || RelateFilterFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RelateFilterFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            TagInputModule,
            LabelModule,
            FormsModule,
            InlineLoadingSpinnerModule,
            ButtonModule,
            ImageModule,
            MultiSelectModule,
            SharedModule,
            DropdownModule,
            InputTextModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RelateFilterFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [RelateFilterFieldComponent],
                exports: [RelateFilterFieldComponent],
                imports: [
                    CommonModule,
                    TagInputModule,
                    LabelModule,
                    FormsModule,
                    InlineLoadingSpinnerModule,
                    ButtonModule,
                    ImageModule,
                    MultiSelectModule,
                    SharedModule,
                    DropdownModule,
                    InputTextModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RelateFilterFieldModule, { declarations: [RelateFilterFieldComponent], imports: [CommonModule,
        TagInputModule,
        LabelModule,
        FormsModule,
        InlineLoadingSpinnerModule,
        ButtonModule,
        ImageModule,
        MultiSelectModule,
        SharedModule,
        DropdownModule,
        InputTextModule], exports: [RelateFilterFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BooleanEditFieldComponent extends BaseBooleanComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function BooleanEditFieldComponent_Factory(t) { return new (t || BooleanEditFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BooleanEditFieldComponent, selectors: [["scrm-boolean-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 4, vars: 1, consts: [[1, "pb-4", "checkbox-field"], [1, "checkbox-container"], ["type", "checkbox", "aria-hidden", "true", 3, "checked", "change"], [1, "checkmark"]], template: function BooleanEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "label", 1)(2, "input", 2);
            i0.ɵɵlistener("change", function BooleanEditFieldComponent_Template_input_change_2_listener() { return ctx.toggle(); });
            i0.ɵɵelementEnd();
            i0.ɵɵelement(3, "span", 3);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("checked", ctx.checked);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BooleanEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-boolean-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"pb-4 checkbox-field\">\n<label class=\"checkbox-container\">\n    <input type=\"checkbox\"\n           [checked]=\"checked\"\n           (change)=\"toggle()\"\n           aria-hidden=\"true\">\n    <span class=\"checkmark\"></span>\n</label>\n</div>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BooleanEditFieldModule {
    static { this.ɵfac = function BooleanEditFieldModule_Factory(t) { return new (t || BooleanEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BooleanEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BooleanEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [BooleanEditFieldComponent],
                exports: [BooleanEditFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BooleanEditFieldModule, { declarations: [BooleanEditFieldComponent], imports: [CommonModule], exports: [BooleanEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharEditFieldModule {
    static { this.ɵfac = function VarcharEditFieldModule_Factory(t) { return new (t || VarcharEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: VarcharEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [VarcharEditFieldComponent],
                exports: [VarcharEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(VarcharEditFieldModule, { declarations: [VarcharEditFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        LabelModule], exports: [VarcharEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BooleanDetailFieldModule {
    static { this.ɵfac = function BooleanDetailFieldModule_Factory(t) { return new (t || BooleanDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BooleanDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BooleanDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [BooleanDetailFieldComponent],
                exports: [BooleanDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BooleanDetailFieldModule, { declarations: [BooleanDetailFieldComponent], imports: [CommonModule], exports: [BooleanDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UrlDetailFieldModule {
    static { this.ɵfac = function UrlDetailFieldModule_Factory(t) { return new (t || UrlDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: UrlDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UrlDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [UrlDetailFieldComponent],
                exports: [UrlDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(UrlDetailFieldModule, { declarations: [UrlDetailFieldComponent], imports: [CommonModule], exports: [UrlDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$C = ["multiSelect"];
function MultiEnumEditFieldComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 6);
} }
function MultiEnumEditFieldComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 7);
} }
function MultiEnumEditFieldComponent_ng_template_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 8);
} }
class MultiEnumEditFieldComponent extends BaseMultiEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay, screenSize, systemConfigStore, primengConfig) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.primengConfig = primengConfig;
        this.placeholderLabel = '';
        this.selectedItemsLabel = '';
        this.emptyFilterLabel = '';
        this.maxSelectedLabels = 20;
        this.selectAll = false;
    }
    ngOnInit() {
        this.checkAndInitAsDynamicEnum();
        this.getTranslatedLabels();
        super.ngOnInit();
        const maxSelectedLabelsForDisplay = this.systemConfigStore.getUi('multiselect_max_number');
        this.screenSize.screenSize$
            .pipe(take(1))
            .subscribe((screenSize) => {
            this.maxSelectedLabels = maxSelectedLabelsForDisplay[screenSize] || this.maxSelectedLabels;
        });
        this.primengConfig.ripple = true;
        this.clearButton = {
            klass: ['btn', 'btn-sm', 'btn-outline-secondary', 'm-0', 'border-0'],
            onClick: (event) => {
                this.onRemove();
            },
            icon: 'cross'
        };
    }
    onAdd() {
        const value = this.selectedValues.map(option => option.value);
        this.field.valueList = value;
        this.field.formControl.setValue(value);
        this.field.formControl.markAsDirty();
        this.calculateSelectAll();
    }
    onSelectAll(event) {
        this.selectAll = event.checked;
        if (this.selectAll) {
            if (this.multiSelect.visibleOptions() && this.multiSelect.visibleOptions().length) {
                this.selectedValues = this.multiSelect.visibleOptions();
            }
            else {
                this.selectedValues = this.options;
            }
            this.onAdd();
        }
        else {
            this.selectedValues = [];
            this.onRemove();
        }
    }
    onRemove() {
        const value = this.selectedValues.map(option => option.value);
        this.field.valueList = value;
        this.field.formControl.setValue(value);
        this.field.formControl.markAsDirty();
        this.calculateSelectAll();
    }
    onClear() {
        this.selectedValues = [];
        this.multiSelect.filterValue = '';
        this.onRemove();
    }
    onPanelShow() {
        this.multiSelect.filterInputChild.nativeElement.focus();
        this.multiSelect.filterValue = '';
        this.calculateSelectAll();
    }
    onFilter() {
        this.calculateSelectAll();
    }
    getTranslatedLabels() {
        this.placeholderLabel = this.languages.getAppString('LBL_SELECT_ITEM') || '';
        this.selectedItemsLabel = this.languages.getAppString('LBL_ITEMS_SELECTED') || '';
        this.emptyFilterLabel = this.languages.getAppString('ERR_SEARCH_NO_RESULTS') || '';
    }
    calculateSelectAll() {
        const visibleOptions = this?.multiSelect?.visibleOptions() ?? [];
        const selectedValuesKeys = (this?.selectedValues ?? []).map(item => item.value);
        if (!visibleOptions.length || !selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        if (visibleOptions.length > selectedValuesKeys.length) {
            this.selectAll = false;
            return;
        }
        this.selectAll = visibleOptions.every(item => selectedValuesKeys.includes(item.value));
    }
    static { this.ɵfac = function MultiEnumEditFieldComponent_Factory(t) { return new (t || MultiEnumEditFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(i7.PrimeNGConfig)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MultiEnumEditFieldComponent, selectors: [["scrm-multienum-edit"]], viewQuery: function MultiEnumEditFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$C, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.multiSelect = _t.first);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 14, consts: [[1, "d-flex", "align-items-center"], [3, "options", "ngModel", "optionLabel", "placeholder", "selectedItemsLabel", "emptyFilterMessage", "maxSelectedLabels", "styleClass", "showToggleAll", "selectAll", "autoOptionFocus", "autofocusFilter", "showClear", "focusOnHover", "ngModelChange", "onChange", "onSelectAllChange", "onRemove", "onPanelShow", "onFilter", "onClear"], ["multiSelect", ""], ["pTemplate", "dropdownicon"], ["pTemplate", "filtericon"], ["pTemplate", "checkicon"], ["image", "down_carret"], ["image", "search"], ["image", "checkbox_cross"]], template: function MultiEnumEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "p-multiSelect", 1, 2);
            i0.ɵɵlistener("ngModelChange", function MultiEnumEditFieldComponent_Template_p_multiSelect_ngModelChange_1_listener($event) { return ctx.selectedValues = $event; })("onChange", function MultiEnumEditFieldComponent_Template_p_multiSelect_onChange_1_listener() { return ctx.onAdd(); })("onSelectAllChange", function MultiEnumEditFieldComponent_Template_p_multiSelect_onSelectAllChange_1_listener($event) { return ctx.onSelectAll($event); })("onRemove", function MultiEnumEditFieldComponent_Template_p_multiSelect_onRemove_1_listener() { return ctx.onRemove(); })("onPanelShow", function MultiEnumEditFieldComponent_Template_p_multiSelect_onPanelShow_1_listener() { return ctx.onPanelShow(); })("onFilter", function MultiEnumEditFieldComponent_Template_p_multiSelect_onFilter_1_listener() { return ctx.onFilter(); })("onClear", function MultiEnumEditFieldComponent_Template_p_multiSelect_onClear_1_listener() { return ctx.onClear(); });
            i0.ɵɵtemplate(3, MultiEnumEditFieldComponent_ng_template_3_Template, 1, 0, "ng-template", 3);
            i0.ɵɵtemplate(4, MultiEnumEditFieldComponent_ng_template_4_Template, 1, 0, "ng-template", 4);
            i0.ɵɵtemplate(5, MultiEnumEditFieldComponent_ng_template_5_Template, 1, 0, "ng-template", 5);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("options", ctx.options)("ngModel", ctx.selectedValues)("optionLabel", "label")("placeholder", ctx.placeholderLabel)("selectedItemsLabel", "{0} " + ctx.selectedItemsLabel)("emptyFilterMessage", ctx.emptyFilterLabel)("maxSelectedLabels", ctx.maxSelectedLabels)("styleClass", "w-100 " + ctx.getInvalidClass())("showToggleAll", true)("selectAll", ctx.selectAll)("autoOptionFocus", false)("autofocusFilter", true)("showClear", true)("focusOnHover", true);
        } }, dependencies: [i5$1.NgControlStatus, i5$1.NgModel, i10.MultiSelect, i7.PrimeTemplate, ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-multienum-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"d-flex align-items-center\">\n    <p-multiSelect\n        #multiSelect\n        [options]=\"options\"\n        [(ngModel)]=\"selectedValues\"\n        [optionLabel]=\"'label'\"\n        (onChange)=\"onAdd()\"\n        (onSelectAllChange)=\"onSelectAll($event)\"\n        (onRemove)=\"onRemove()\"\n        (onPanelShow)=\"onPanelShow()\"\n        (onFilter)=\"onFilter()\"\n        [placeholder]=\"placeholderLabel\"\n        [selectedItemsLabel]=\"'{0} ' + selectedItemsLabel\"\n        [emptyFilterMessage]=\"emptyFilterLabel\"\n        [maxSelectedLabels]=\"maxSelectedLabels\"\n        [styleClass]=\"'w-100 ' + getInvalidClass()\"\n        [showToggleAll]=\"true\"\n        [selectAll]=\"selectAll\"\n        [autoOptionFocus]=\"false\"\n        [autofocusFilter]=\"true\"\n        [showClear]=\"true\"\n        (onClear)=\"onClear()\"\n        [focusOnHover]=\"true\"\n    >\n        <ng-template pTemplate=\"dropdownicon\">\n            <scrm-image image=\"down_carret\"></scrm-image>\n        </ng-template>\n        <ng-template pTemplate=\"filtericon\">\n            <scrm-image image=\"search\"></scrm-image>\n        </ng-template>\n        <ng-template pTemplate=\"checkicon\">\n            <scrm-image image=\"checkbox_cross\"></scrm-image>\n        </ng-template>\n    </p-multiSelect>\n</div>\n\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }, { type: i7.PrimeNGConfig }]; }, { multiSelect: [{
            type: ViewChild,
            args: ['multiSelect']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function IntDetailFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r0.field.value);
} }
function IntDetailFieldComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "formatNumber");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, ctx_r1.field.value), "\n");
} }
class IntDetailFieldComponent extends BaseNumberComponent {
    constructor(userPreferences, systemConfig, typeFormatter, logic, logicDisplay) {
        super(userPreferences, systemConfig, typeFormatter, logic, logicDisplay);
        this.userPreferences = userPreferences;
        this.systemConfig = systemConfig;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function IntDetailFieldComponent_Factory(t) { return new (t || IntDetailFieldComponent)(i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: IntDetailFieldComponent, selectors: [["scrm-int-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 4, consts: [[4, "ngIf"]], template: function IntDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, IntDetailFieldComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(1, IntDetailFieldComponent_ng_container_1_Template, 3, 3, "ng-container", 0);
            i0.ɵɵpipe(2, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.format);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.format && i0.ɵɵpipeBind1(2, 2, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe, FormatNumberPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IntDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-int-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!format\">{{ field.value }}</ng-container>\n<ng-container *ngIf=\"format && (vm$ | async) as vm\">\n    {{field.value | formatNumber}}\n</ng-container>\n" }]
    }], function () { return [{ type: UserPreferenceStore }, { type: SystemConfigStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MultiEnumEditFieldModule {
    static { this.ɵfac = function MultiEnumEditFieldModule_Factory(t) { return new (t || MultiEnumEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MultiEnumEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            MultiSelectModule,
            ButtonModule,
            DropdownModule,
            ImageModule,
            InputTextModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MultiEnumEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [MultiEnumEditFieldComponent],
                exports: [MultiEnumEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    MultiSelectModule,
                    ButtonModule,
                    DropdownModule,
                    ImageModule,
                    InputTextModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MultiEnumEditFieldModule, { declarations: [MultiEnumEditFieldComponent], imports: [CommonModule,
        FormsModule,
        MultiSelectModule,
        ButtonModule,
        DropdownModule,
        ImageModule,
        InputTextModule], exports: [MultiEnumEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IntDetailFieldModule {
    static { this.ɵfac = function IntDetailFieldModule_Factory(t) { return new (t || IntDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IntDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormatNumberModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IntDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [IntDetailFieldComponent],
                exports: [IntDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormatNumberModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IntDetailFieldModule, { declarations: [IntDetailFieldComponent], imports: [CommonModule,
        FormatNumberModule], exports: [IntDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class VarcharDetailFieldModule {
    static { this.ɵfac = function VarcharDetailFieldModule_Factory(t) { return new (t || VarcharDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: VarcharDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(VarcharDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [VarcharDetailFieldComponent],
                exports: [VarcharDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(VarcharDetailFieldModule, { declarations: [VarcharDetailFieldComponent], imports: [CommonModule], exports: [VarcharDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TextEditFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    get rows() {
        if (this.field.metadata && this.field.metadata.rows) {
            return this.field.metadata.rows;
        }
        return 6;
    }
    get cols() {
        if (this.field.metadata && this.field.metadata.cols) {
            return this.field.metadata.cols;
        }
        return 20;
    }
    static { this.ɵfac = function TextEditFieldComponent_Factory(t) { return new (t || TextEditFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TextEditFieldComponent, selectors: [["scrm-text-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 6, consts: [[3, "rows", "cols", "ngClass", "formControl"]], template: function TextEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "textarea", 0);
        } if (rf & 2) {
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("rows", ctx.rows)("cols", ctx.cols)("ngClass", ctx.klass)("formControl", ctx.field.formControl);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-text-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<textarea [rows]=\"rows\"\n          [cols]=\"cols\"\n          [ngClass]=\"klass\"\n          [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n          [formControl]=\"field.formControl\">\n</textarea>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DateFilterFieldModule {
    static { this.ɵfac = function DateFilterFieldModule_Factory(t) { return new (t || DateFilterFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DateFilterFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            NgbDatepickerModule,
            ButtonModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateFilterFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DateFilterFieldComponent],
                exports: [DateFilterFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    NgbDatepickerModule,
                    ButtonModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DateFilterFieldModule, { declarations: [DateFilterFieldComponent], imports: [CommonModule,
        FormsModule,
        NgbDatepickerModule,
        ButtonModule,
        ReactiveFormsModule], exports: [DateFilterFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TextEditFieldModule {
    static { this.ɵfac = function TextEditFieldModule_Factory(t) { return new (t || TextEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TextEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [TextEditFieldComponent],
                exports: [TextEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TextEditFieldModule, { declarations: [TextEditFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule], exports: [TextEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function DropdownEnumEditFieldComponent_ng_container_2_option_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 4);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r2 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵclassMap(ctx_r1.getId(item_r2));
    i0.ɵɵproperty("ngValue", item_r2.value);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", item_r2.label, " ");
} }
function DropdownEnumEditFieldComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DropdownEnumEditFieldComponent_ng_container_2_option_1_Template, 2, 5, "option", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r0.options);
} }
class DropdownEnumEditFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        this.checkAndInitAsDynamicEnum();
        super.ngOnInit();
        this.subscribeValueChanges();
    }
    getId(item) {
        return this.field.name + '-' + item.value;
    }
    static { this.ɵfac = function DropdownEnumEditFieldComponent_Factory(t) { return new (t || DropdownEnumEditFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DropdownEnumEditFieldComponent, selectors: [["scrm-dropdownenum-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 2, consts: [[1, "dropdownenum"], [1, "custom-select", "custom-select-sm", 3, "formControl"], [4, "ngIf"], [3, "class", "ngValue", 4, "ngFor", "ngForOf"], [3, "ngValue"]], template: function DropdownEnumEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "select", 1);
            i0.ɵɵtemplate(2, DropdownEnumEditFieldComponent_ng_container_2_Template, 2, 1, "ng-container", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("formControl", ctx.field.formControl);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.options && ctx.options.length);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i5$1.NgSelectOption, i5$1.ɵNgSelectMultipleOption, i5$1.SelectControlValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownEnumEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dropdownenum-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"dropdownenum\">\n    <select [formControl]=\"field.formControl\" class=\"custom-select custom-select-sm\">\n        <ng-container *ngIf=\"this.options && this.options.length\">\n            <option *ngFor=\"let item of this.options;\"\n                    class=\"{{getId(item)}}\"\n                    [ngValue]=\"item.value\">\n                {{item.label}}\n            </option>\n        </ng-container>\n    </select>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DropdownEnumEditFieldModule {
    static { this.ɵfac = function DropdownEnumEditFieldModule_Factory(t) { return new (t || DropdownEnumEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DropdownEnumEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownEnumEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DropdownEnumEditFieldComponent],
                exports: [DropdownEnumEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DropdownEnumEditFieldModule, { declarations: [DropdownEnumEditFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule], exports: [DropdownEnumEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DropdownEnumDetailFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function DropdownEnumDetailFieldComponent_Factory(t) { return new (t || DropdownEnumDetailFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DropdownEnumDetailFieldComponent, selectors: [["scrm-dropdownenum-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function DropdownEnumDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.valueLabel, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownEnumDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dropdownenum-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{valueLabel}}\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DropdownEnumDetailFieldModule {
    static { this.ɵfac = function DropdownEnumDetailFieldModule_Factory(t) { return new (t || DropdownEnumDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DropdownEnumDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DropdownEnumDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DropdownEnumDetailFieldComponent],
                exports: [DropdownEnumDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DropdownEnumDetailFieldModule, { declarations: [DropdownEnumDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [DropdownEnumDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RadioEnumDetailFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function RadioEnumDetailFieldComponent_Factory(t) { return new (t || RadioEnumDetailFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RadioEnumDetailFieldComponent, selectors: [["scrm-radioenum-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function RadioEnumDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.valueLabel, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RadioEnumDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-radioenum-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{valueLabel}}\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RadioEnumDetailFieldModule {
    static { this.ɵfac = function RadioEnumDetailFieldModule_Factory(t) { return new (t || RadioEnumDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RadioEnumDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RadioEnumDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [RadioEnumDetailFieldComponent],
                exports: [RadioEnumDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RadioEnumDetailFieldModule, { declarations: [RadioEnumDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [RadioEnumDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RadioEnumEditFieldComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "input", 2);
    i0.ɵɵelementStart(2, "label", 3);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r1 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵclassMapInterpolate1("form-check radioenum-input ", ctx_r0.getId(item_r1), "");
    i0.ɵɵclassProp("form-check-inline", ctx_r0.displayDirection === "row");
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("id", ctx_r0.getId(item_r1));
    i0.ɵɵproperty("checked", ctx_r0.field.value === item_r1.value)("formControl", ctx_r0.field.formControl)("value", item_r1.value)("name", ctx_r0.field.name);
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("for", ctx_r0.getId(item_r1));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", item_r1.label, " ");
} }
class RadioEnumEditFieldComponent extends BaseEnumComponent {
    constructor(languages, typeFormatter, logic, logicDisplay) {
        super(languages, typeFormatter, logic, logicDisplay);
        this.languages = languages;
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    get displayDirection() {
        if (!this.field || !this.field.definition || !this.field.definition.displayDirection) {
            return '';
        }
        return this.field.definition.displayDirection;
    }
    ngOnInit() {
        this.checkAndInitAsDynamicEnum();
        super.ngOnInit();
        this.subscribeValueChanges();
        if (this.record && this.record.formGroup) {
            this.formGroup = this.record.formGroup;
        }
        else {
            this.formGroup = new UntypedFormGroup({});
            this.formGroup.addControl(this.field.name, this.field.formControl);
        }
    }
    getId(item) {
        return this.field.name + '-' + item.value;
    }
    buildOptionsArray(appStrings) {
        this.options = [];
        Object.keys(this.optionsMap).forEach(key => {
            this.options.push({
                value: key,
                label: this.optionsMap[key]
            });
        });
        if (this.isDynamicEnum) {
            this.buildDynamicEnumOptions(appStrings);
        }
    }
    static { this.ɵfac = function RadioEnumEditFieldComponent_Factory(t) { return new (t || RadioEnumEditFieldComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RadioEnumEditFieldComponent, selectors: [["scrm-radioenum-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[1, "radioenum"], [3, "form-check-inline", "class", 4, "ngFor", "ngForOf"], ["type", "radio", 1, "form-check-input", 3, "checked", "formControl", "value", "name", "id"], [1, "form-check-label", 3, "for"]], template: function RadioEnumEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, RadioEnumEditFieldComponent_div_1_Template, 4, 12, "div", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngForOf", ctx.options);
        } }, dependencies: [i2.NgForOf, i5$1.DefaultValueAccessor, i5$1.RadioControlValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RadioEnumEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-radioenum-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"radioenum\">\n    <div *ngFor=\"let item of this.options;\"\n         [class.form-check-inline]=\"displayDirection === 'row'\"\n         class=\"form-check radioenum-input {{getId(item)}}\">\n        <input [checked]=\"field.value === item.value\"\n               [formControl]=\"field.formControl\"\n               [value]=\"item.value\"\n               [name]=\"field.name\"\n               class=\"form-check-input\"\n               id=\"{{getId(item)}}\"\n               type=\"radio\"\n        />\n        <label class=\"form-check-label\"\n               for=\"{{getId(item)}}\">\n            {{item.label}}\n        </label>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RadioEnumEditFieldModule {
    static { this.ɵfac = function RadioEnumEditFieldModule_Factory(t) { return new (t || RadioEnumEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RadioEnumEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RadioEnumEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [RadioEnumEditFieldComponent],
                exports: [RadioEnumEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RadioEnumEditFieldModule, { declarations: [RadioEnumEditFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule], exports: [RadioEnumEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HtmlDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function HtmlDetailFieldComponent_Factory(t) { return new (t || HtmlDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: HtmlDetailFieldComponent, selectors: [["scrm-html-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[1, "field-html", "text-break", 3, "innerHTML"]], template: function HtmlDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "div", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("innerHTML", ctx.field.value, i0.ɵɵsanitizeHtml);
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-html-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"field-html text-break\" [innerHTML]=\"field.value\"></div>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HtmlDetailFieldModule {
    static { this.ɵfac = function HtmlDetailFieldModule_Factory(t) { return new (t || HtmlDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: HtmlDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [HtmlDetailFieldComponent],
                exports: [HtmlDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(HtmlDetailFieldModule, { declarations: [HtmlDetailFieldComponent], imports: [CommonModule,
        FormsModule], exports: [HtmlDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PasswordDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function PasswordDetailFieldComponent_Factory(t) { return new (t || PasswordDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PasswordDetailFieldComponent, selectors: [["scrm-password-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 0, template: function PasswordDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "span");
            i0.ɵɵtext(1, "*****");
            i0.ɵɵelementEnd();
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PasswordDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-password-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<span>*****</span>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PasswordDetailFieldModule {
    static { this.ɵfac = function PasswordDetailFieldModule_Factory(t) { return new (t || PasswordDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PasswordDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PasswordDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [PasswordDetailFieldComponent],
                exports: [PasswordDetailFieldComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PasswordDetailFieldModule, { declarations: [PasswordDetailFieldComponent], imports: [CommonModule], exports: [PasswordDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PasswordEditFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.subscribeValueChanges();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    static { this.ɵfac = function PasswordEditFieldComponent_Factory(t) { return new (t || PasswordEditFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PasswordEditFieldComponent, selectors: [["scrm-password-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 5, consts: [["type", "password", 3, "formControl", "ngClass", "value"]], template: function PasswordEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "input", 0);
        } if (rf & 2) {
            i0.ɵɵclassProp("is-invalid", ctx.validateOnlyOnSubmit ? ctx.isInvalid() : ctx.field.formControl.invalid && ctx.field.formControl.touched);
            i0.ɵɵproperty("formControl", ctx.field.formControl)("ngClass", ctx.klass)("value", ctx.field.value);
        } }, dependencies: [i2.NgClass, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.FormControlDirective], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PasswordEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-password-edit', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<input [class.is-invalid]=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\"\n       [formControl]=\"field.formControl\"\n       [ngClass]=\"klass\"\n       [value]=\"field.value\"\n       type=\"password\">\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PasswordEditFieldModule {
    static { this.ɵfac = function PasswordEditFieldModule_Factory(t) { return new (t || PasswordEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PasswordEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ReactiveFormsModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PasswordEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [PasswordEditFieldComponent],
                exports: [PasswordEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ReactiveFormsModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PasswordEditFieldModule, { declarations: [PasswordEditFieldComponent], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        LabelModule], exports: [PasswordEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TinymceDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, config, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.config = config;
        this.logicDisplay = logicDisplay;
        this.settings = {};
        this.initialValue = '';
    }
    ngOnInit() {
        super.ngOnInit();
        this.initSettings();
        this.initialValue = this.getValue();
    }
    initSettings() {
        const defaults = {
            toolbar: false,
            menubar: false,
            readonly: true,
            deprecation_warnings: false
        };
        const ui = this.config.getConfigValue('ui');
        const systemDefaults = ui?.tinymce?.detail ?? {};
        const fieldConfig = this.field?.metadata?.tinymce?.detail ?? {};
        let settings = {};
        settings = merge$1(settings, defaults, systemDefaults, fieldConfig);
        this.settings = settings;
    }
    getValue() {
        let value = this.field.value;
        if (value === '' && (this.field.default ?? false)) {
            value = this.field.default;
        }
        return value;
    }
    static { this.ɵfac = function TinymceDetailFieldComponent_Factory(t) { return new (t || TinymceDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TinymceDetailFieldComponent, selectors: [["scrm-tinymce-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 3, consts: [[1, "field-html", "text-break", 3, "initialValue", "init", "disabled"]], template: function TinymceDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "editor", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("initialValue", ctx.initialValue)("init", ctx.settings)("disabled", true);
        } }, dependencies: [i5$3.EditorComponent], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TinymceDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-tinymce-detail', changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<editor\n    class=\"field-html text-break\"\n    [initialValue]=\"initialValue\"\n    [init]=\"settings\"\n    [disabled]=\"true\"\n></editor>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: SystemConfigStore }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TinymceDetailFieldModule {
    static { this.ɵfac = function TinymceDetailFieldModule_Factory(t) { return new (t || TinymceDetailFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TinymceDetailFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [
            { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }
        ], imports: [CommonModule,
            FormsModule,
            EditorModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TinymceDetailFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [TinymceDetailFieldComponent],
                exports: [TinymceDetailFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    EditorModule,
                    ReactiveFormsModule
                ],
                providers: [
                    { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TinymceDetailFieldModule, { declarations: [TinymceDetailFieldComponent], imports: [CommonModule,
        FormsModule,
        EditorModule,
        ReactiveFormsModule], exports: [TinymceDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TinymceEditFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay, config) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.config = config;
        this.settings = {};
        this.modelEvents = 'change';
        this.ignoreEvents = "onKeyDown,onKeyPress,onKeyUp,onSelectionChange";
        this.value = '';
    }
    ngOnInit() {
        super.ngOnInit();
        this.initSettings();
        this.subscribeValueChanges();
        this.value = this.getValue();
    }
    ngOnDestroy() {
        this.unsubscribeAll();
    }
    initSettings() {
        const defaults = {
            height: 300,
            menubar: false,
            deprecation_warnings: false,
            plugins: [
                'advlist autolink lists link image charmap print preview anchor',
                'searchreplace visualblocks code fullscreen',
                'insertdatetime media table paste code help wordcount'
            ],
            toolbar: 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify |  bullist numlist outdent indent | removeformat | help',
            toolbar_mode: 'floating',
        };
        const ui = this.config.getConfigValue('ui');
        const systemDefaults = ui?.tinymce?.edit ?? {};
        const fieldConfig = this?.field?.metadata?.tinymce?.edit ?? {};
        let settings = {};
        settings = merge$1(settings, defaults, systemDefaults, fieldConfig);
        this.modelEvents = settings?.modelEvents ?? 'change';
        this.ignoreEvents = settings?.ignoreEvents ?? "onKeyDown,onKeyPress,onKeyUp,onSelectionChange";
        this.settings = settings;
    }
    setModel() {
        this.field.formControl.setValue(this.value);
    }
    getValue() {
        let value = this.field.value;
        if (value === '' && (this.field.default ?? false)) {
            value = this.field.default;
        }
        return value;
    }
    static { this.ɵfac = function TinymceEditFieldComponent_Factory(t) { return new (t || TinymceEditFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TinymceEditFieldComponent, selectors: [["scrm-tinymce-edit"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 4, consts: [[1, "field-html", 3, "init", "modelEvents", "ignoreEvents", "formControl"]], template: function TinymceEditFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "editor", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("init", ctx.settings)("modelEvents", ctx.modelEvents)("ignoreEvents", ctx.ignoreEvents)("formControl", ctx.field.formControl);
        } }, dependencies: [i5$1.NgControlStatus, i5$3.EditorComponent, i5$1.FormControlDirective], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TinymceEditFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-tinymce-edit', changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<editor\n    class=\"field-html\"\n    [init]=\"settings\"\n    [modelEvents]=\"modelEvents\"\n    [ignoreEvents]=\"ignoreEvents\"\n    [formControl]=\"field.formControl\"\n></editor>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TinymceEditFieldModule {
    static { this.ɵfac = function TinymceEditFieldModule_Factory(t) { return new (t || TinymceEditFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TinymceEditFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [
            { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }
        ], imports: [CommonModule,
            FormsModule,
            EditorModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TinymceEditFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [TinymceEditFieldComponent],
                exports: [TinymceEditFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    EditorModule,
                    ReactiveFormsModule
                ],
                providers: [
                    { provide: TINYMCE_SCRIPT_SRC, useValue: 'tinymce/tinymce.min.js' }
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TinymceEditFieldModule, { declarations: [TinymceEditFieldComponent], imports: [CommonModule,
        FormsModule,
        EditorModule,
        ReactiveFormsModule], exports: [TinymceEditFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2022 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IconDetailFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function IconDetailFieldComponent_Factory(t) { return new (t || IconDetailFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: IconDetailFieldComponent, selectors: [["scrm-icon-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "image"]], template: function IconDetailFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "scrm-image", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("image", ctx.field.value);
        } }, dependencies: [ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IconDetailFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-icon-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2022 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-image [image]=\"field.value\"></scrm-image>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class IconListFieldModule {
    static { this.ɵfac = function IconListFieldModule_Factory(t) { return new (t || IconListFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: IconListFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IconListFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [IconDetailFieldComponent],
                exports: [IconDetailFieldComponent],
                imports: [
                    CommonModule,
                    ImageModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(IconListFieldModule, { declarations: [IconDetailFieldComponent], imports: [CommonModule,
        ImageModule], exports: [IconDetailFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function TextListFieldComponent_div_0_br_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "br");
} }
function TextListFieldComponent_div_0_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1, " ... ");
    i0.ɵɵelementContainerEnd();
} }
function TextListFieldComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "span");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, TextListFieldComponent_div_0_br_3_Template, 1, 0, "br", 2);
    i0.ɵɵtemplate(4, TextListFieldComponent_div_0_ng_container_4_Template, 2, 0, "ng-container", 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const value_r1 = ctx.$implicit;
    const last_r2 = ctx.last;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngClass", ctx_r0.klass)("title", ctx_r0.field.value);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(value_r1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !last_r2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", last_r2 && ctx_r0.isTruncated);
} }
class TextListFieldComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.isTruncated = false;
    }
    truncateValue(value) {
        const chars_limit = 50;
        let truncatedValue = value.slice(0, chars_limit);
        let lines = truncatedValue.split("\n");
        const maxLines = 3;
        const truncatedLines = lines.slice(0, maxLines);
        this.isTruncated = truncatedValue.length !== value.length || lines.length > maxLines;
        return truncatedLines;
    }
    static { this.ɵfac = function TextListFieldComponent_Factory(t) { return new (t || TextListFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TextListFieldComponent, selectors: [["scrm-text-list"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "ngClass", "title", 4, "ngFor", "ngForOf"], [3, "ngClass", "title"], [4, "ngIf"]], template: function TextListFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, TextListFieldComponent_div_0_Template, 5, 5, "div", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngForOf", ctx.truncateValue(ctx.field.value));
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextListFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-text-list', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div [ngClass]=\"klass\" [title]=\"field.value\"\n     *ngFor=\"let value of truncateValue(field.value); let last = last; let first= first\">\n    <span>{{value}}</span> <br *ngIf=\"!last\">\n    <ng-container *ngIf=\"last && isTruncated\">\n        ...\n    </ng-container>\n</div>\n\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TextListFieldModule {
    static { this.ɵfac = function TextListFieldModule_Factory(t) { return new (t || TextListFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TextListFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextListFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [TextListFieldComponent],
                exports: [TextListFieldComponent],
                imports: [
                    CommonModule,
                    FormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TextListFieldModule, { declarations: [TextListFieldComponent], imports: [CommonModule,
        FormsModule], exports: [TextListFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const baseFieldModules = [
    VarcharDetailFieldModule,
    VarcharEditFieldModule,
    VarcharFilterFieldModule,
    PasswordDetailFieldModule,
    PasswordEditFieldModule,
    IntDetailFieldModule,
    IconListFieldModule,
    FileDetailFieldModule,
    FloatDetailFieldModule,
    PhoneDetailFieldModule,
    DateDetailFieldModule,
    DateEditFieldModule,
    DateFilterFieldModule,
    DateTimeDetailFieldModule,
    DateTimeEditFieldModule,
    DateTimeFilterFieldModule,
    UrlDetailFieldModule,
    CurrencyDetailFieldModule,
    EmailListFieldsModule,
    TextDetailFieldModule,
    TextEditFieldModule,
    TextListFieldModule,
    RelateDetailFieldsModule,
    RelateEditFieldModule,
    RelateFilterFieldModule,
    FullNameDetailFieldsModule,
    EnumDetailFieldModule,
    EnumEditFieldModule,
    DropdownEnumDetailFieldModule,
    DropdownEnumEditFieldModule,
    RadioEnumDetailFieldModule,
    RadioEnumEditFieldModule,
    MultiEnumDetailFieldModule,
    MultiEnumEditFieldModule,
    MultiEnumFilterFieldModule,
    BooleanDetailFieldModule,
    BooleanEditFieldModule,
    HtmlDetailFieldModule,
    TinymceDetailFieldModule,
    TinymceEditFieldModule
];
const baseFieldComponents = [
    VarcharDetailFieldComponent,
    VarcharEditFieldComponent,
    VarcharFilterFieldComponent,
    PasswordDetailFieldComponent,
    PasswordEditFieldComponent,
    IntDetailFieldComponent,
    FileDetailFieldComponent,
    FloatDetailFieldComponent,
    PhoneDetailFieldComponent,
    DateDetailFieldComponent,
    DateEditFieldComponent,
    DateFilterFieldComponent,
    DateTimeDetailFieldComponent,
    DateTimeEditFieldComponent,
    DateTimeFilterFieldComponent,
    UrlDetailFieldComponent,
    IconDetailFieldComponent,
    CurrencyDetailFieldComponent,
    EmailListFieldsComponent,
    TextDetailFieldComponent,
    TextEditFieldComponent,
    TextListFieldComponent,
    RelateDetailFieldComponent,
    RelateEditFieldComponent,
    RelateFilterFieldComponent,
    FullNameDetailFieldsComponent,
    EnumDetailFieldComponent,
    EnumEditFieldComponent,
    DropdownEnumDetailFieldComponent,
    DropdownEnumEditFieldComponent,
    RadioEnumDetailFieldComponent,
    RadioEnumEditFieldComponent,
    MultiEnumDetailFieldComponent,
    MultiEnumEditFieldComponent,
    MultiEnumFilterFieldComponent,
    BooleanDetailFieldComponent,
    BooleanEditFieldComponent,
    HtmlDetailFieldComponent,
    TinymceDetailFieldComponent,
    TinymceEditFieldComponent
];
const baseViewFieldsMap = {
    'varchar.list': VarcharDetailFieldComponent,
    'varchar.detail': VarcharDetailFieldComponent,
    'varchar.edit': VarcharEditFieldComponent,
    'varchar.filter': VarcharFilterFieldComponent,
    'password.list': PasswordDetailFieldComponent,
    'password.detail': PasswordDetailFieldComponent,
    'password.edit': PasswordEditFieldComponent,
    'char.list': VarcharDetailFieldComponent,
    'char.detail': VarcharDetailFieldComponent,
    'int.list': IntDetailFieldComponent,
    'int.detail': IntDetailFieldComponent,
    'file.detail': FileDetailFieldComponent,
    'file.list': FileDetailFieldComponent,
    'float.list': FloatDetailFieldComponent,
    'float.detail': FloatDetailFieldComponent,
    'phone.list': PhoneDetailFieldComponent,
    'phone.detail': PhoneDetailFieldComponent,
    'date.list': DateDetailFieldComponent,
    'date.detail': DateDetailFieldComponent,
    'date.edit': DateEditFieldComponent,
    'date.filter': DateFilterFieldComponent,
    'datetime.list': DateTimeDetailFieldComponent,
    'datetime.detail': DateTimeDetailFieldComponent,
    'datetime.edit': DateTimeEditFieldComponent,
    'datetime.filter': DateFilterFieldComponent,
    'url.list': UrlDetailFieldComponent,
    'url.detail': UrlDetailFieldComponent,
    'icon.detail': IconDetailFieldComponent,
    'icon.edit': IconDetailFieldComponent,
    'icon.list': IconDetailFieldComponent,
    'link.list': UrlDetailFieldComponent,
    'link.detail': UrlDetailFieldComponent,
    'currency.list': CurrencyDetailFieldComponent,
    'currency.detail': CurrencyDetailFieldComponent,
    'email.list': EmailListFieldsComponent,
    'email.detail': EmailListFieldsComponent,
    'text.detail': TextDetailFieldComponent,
    'text.edit': TextEditFieldComponent,
    'text.list': TextListFieldComponent,
    'relate.list': RelateDetailFieldComponent,
    'relate.edit': RelateEditFieldComponent,
    'relate.detail': RelateDetailFieldComponent,
    'relate.filter': RelateFilterFieldComponent,
    'fullname.list': FullNameDetailFieldsComponent,
    'fullname.detail': FullNameDetailFieldsComponent,
    'enum-radio.list': RadioEnumDetailFieldComponent,
    'enum-radio.detail': RadioEnumDetailFieldComponent,
    'enum-radio.edit': RadioEnumEditFieldComponent,
    'radioenum.list': RadioEnumDetailFieldComponent,
    'radioenum.detail': RadioEnumDetailFieldComponent,
    'radioenum.edit': RadioEnumEditFieldComponent,
    'radioenum.filter': MultiEnumFilterFieldComponent,
    'enum-dropdown.list': DropdownEnumDetailFieldComponent,
    'enum-dropdown.detail': DropdownEnumDetailFieldComponent,
    'enum-dropdown.edit': DropdownEnumEditFieldComponent,
    'enum-chips.list': EnumDetailFieldComponent,
    'enum-chips.detail': EnumDetailFieldComponent,
    'enum-chips.edit': EnumEditFieldComponent,
    'enum.list': DropdownEnumDetailFieldComponent,
    'enum.detail': DropdownEnumDetailFieldComponent,
    'enum.edit': DropdownEnumEditFieldComponent,
    'enum.filter': MultiEnumFilterFieldComponent,
    'multienum.list': MultiEnumDetailFieldComponent,
    'multienum.detail': MultiEnumDetailFieldComponent,
    'multienum.edit': MultiEnumEditFieldComponent,
    'multienum.filter': MultiEnumFilterFieldComponent,
    'dynamicenum.list': DropdownEnumDetailFieldComponent,
    'dynamicenum.detail': DropdownEnumDetailFieldComponent,
    'dynamicenum.edit': DropdownEnumEditFieldComponent,
    'dynamicenum.filter': MultiEnumFilterFieldComponent,
    'boolean.list': BooleanDetailFieldComponent,
    'boolean.detail': BooleanDetailFieldComponent,
    'boolean.edit': BooleanEditFieldComponent,
    'bool.list': BooleanDetailFieldComponent,
    'bool.detail': BooleanDetailFieldComponent,
    'bool.edit': BooleanEditFieldComponent,
    'bool.filter': MultiEnumFilterFieldComponent,
    'html.detail': TinymceDetailFieldComponent,
    'html.edit': TinymceEditFieldComponent
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldRegistry {
    constructor() {
        this.init();
    }
    register(module, type, mode, component) {
        this.map.addEntry(module, BaseFieldRegistry.getKey(type, mode), component);
    }
    registerField(module, field, mode, component) {
        this.fieldMap.addEntry(module, BaseFieldRegistry.getKey(field, mode), component);
    }
    exclude(module, key) {
        this.map.excludeEntry(module, key);
    }
    getDisplayType(module, type, displayType, mode, field) {
        const displayTypeKey = this.getDisplayTypeKey(type, displayType);
        if (this.hasFieldOverride(module, field, mode)) {
            return this.getFieldOverride(module, type, mode, field);
        }
        if (displayType && this.has(module, displayTypeKey, mode)) {
            return this.get(module, displayTypeKey, mode, field);
        }
        return this.get(module, type, mode, field);
    }
    get(module, type, mode, field) {
        const moduleFields = this.map.getGroupEntries(module);
        let key = BaseFieldRegistry.getKey(type, mode);
        if (moduleFields[key]) {
            return moduleFields[key];
        }
        if (mode === 'massupdate') {
            key = BaseFieldRegistry.getKey(type, 'edit');
            if (moduleFields[key]) {
                return moduleFields[key];
            }
        }
        const defaultKey = BaseFieldRegistry.getKey('varchar', mode);
        return moduleFields[defaultKey];
    }
    getFieldOverride(module, type, mode, field) {
        const moduleFields = this.fieldMap.getGroupEntries(module);
        let key = BaseFieldRegistry.getKey(field, mode);
        if (moduleFields[key]) {
            return moduleFields[key];
        }
        if (mode === 'massupdate') {
            key = BaseFieldRegistry.getKey(field, 'edit');
            if (moduleFields[key]) {
                return moduleFields[key];
            }
        }
        return null;
    }
    has(module, type, mode) {
        const moduleFields = this.map.getGroupEntries(module);
        const key = BaseFieldRegistry.getKey(type, mode);
        return !!moduleFields[key];
    }
    hasFieldOverride(module, field, mode) {
        const moduleFields = this.fieldMap.getGroupEntries(module);
        const key = BaseFieldRegistry.getKey(field, mode);
        return !!moduleFields[key];
    }
    static getKey(type, mode) {
        return type + '.' + mode;
    }
    getDisplayTypeKey(type, displayType) {
        if (!type || !displayType) {
            return '';
        }
        return type + '-' + displayType;
    }
    init() {
        this.map = new OverridableMap();
        this.fieldMap = new OverridableMap();
        Object.keys(this.getDefaultMap()).forEach(key => {
            const [type, mode] = key.split('.', 2);
            this.register('default', type, mode, this.getDefaultMap()[key]);
        });
    }
    getDefaultMap() {
        return {};
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StandardFieldRegistry extends BaseFieldRegistry {
    constructor() {
        super();
    }
    getDefaultMap() {
        return baseViewFieldsMap;
    }
    static { this.ɵfac = function StandardFieldRegistry_Factory(t) { return new (t || StandardFieldRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StandardFieldRegistry, factory: StandardFieldRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StandardFieldRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LinkRouteAsyncActionService {
    constructor(asyncActionService) {
        this.asyncActionService = asyncActionService;
    }
    run(linkAsyncAction, field, record) {
        const data = {
            payload: {
                fieldName: field.name ?? '',
                fieldValue: field.value ?? '',
            },
            record: {
                id: record.id ?? '',
                type: record.type ?? '',
                module: record.module ?? '',
                favorite: record.favorite ?? '',
                attributes: record.attributes ?? {},
                acls: record.acls ?? []
            }
        };
        this.asyncActionService.run(linkAsyncAction, data);
    }
    static { this.ɵfac = function LinkRouteAsyncActionService_Factory(t) { return new (t || LinkRouteAsyncActionService)(i0.ɵɵinject(AsyncActionService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LinkRouteAsyncActionService, factory: LinkRouteAsyncActionService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LinkRouteAsyncActionService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AsyncActionService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$B = function (a0, a1, a2, a3, a4, a5) { return { "mode": a0, "originalMode": a1, "field": a2, "klass": a3, "record": a4, "parent": a5 }; };
function DynamicFieldComponent_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 1);
    i0.ɵɵlistener("click", function DynamicFieldComponent_ng_container_0_ng_container_1_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r6.onClick()); });
    i0.ɵɵelement(2, "ndc-dynamic", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r3.componentType)("ndcDynamicInputs", i0.ɵɵpureFunction6(2, _c0$B, ctx_r3.mode, ctx_r3.originalMode, ctx_r3.field, ctx_r3.klass, ctx_r3.record, ctx_r3.parent));
} }
function DynamicFieldComponent_ng_container_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 3);
    i0.ɵɵelement(2, "ndc-dynamic", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", ctx_r4.getLink())("queryParams", ctx_r4.record == null ? null : ctx_r4.record.metadata == null ? null : ctx_r4.record.metadata.queryParams);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r4.componentType)("ndcDynamicInputs", i0.ɵɵpureFunction6(4, _c0$B, ctx_r4.mode, ctx_r4.originalMode, ctx_r4.field, ctx_r4.klass, ctx_r4.record, ctx_r4.parent));
} }
function DynamicFieldComponent_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "ndc-dynamic", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r5.componentType)("ndcDynamicInputs", i0.ɵɵpureFunction6(2, _c0$B, ctx_r5.mode, ctx_r5.originalMode, ctx_r5.field, ctx_r5.klass, ctx_r5.record, ctx_r5.parent));
} }
function DynamicFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DynamicFieldComponent_ng_container_0_ng_container_1_Template, 3, 9, "ng-container", 0);
    i0.ɵɵtemplate(2, DynamicFieldComponent_ng_container_0_ng_container_2_Template, 3, 11, "ng-container", 0);
    i0.ɵɵtemplate(3, DynamicFieldComponent_ng_container_0_ng_container_3_Template, 2, 9, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.hasOnClick());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.isLink() && !ctx_r0.hasOnClick());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.isLink() && !ctx_r0.hasOnClick());
} }
function DynamicFieldComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 4);
    i0.ɵɵelement(2, "div", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
const _c1$b = function (a0) { return { field: a0 }; };
function DynamicFieldComponent_ng_container_2_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵelement(1, "scrm-dynamic-label", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r10 = ctx.$implicit;
    const ctx_r9 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("context", ctx_r9.getMessageContext(item_r10.value, ctx_r9.record))("fields", i0.ɵɵpureFunction1(3, _c1$b, ctx_r9.field))("labelKey", ctx_r9.getMessageLabelKey(item_r10.value));
} }
function DynamicFieldComponent_ng_container_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DynamicFieldComponent_ng_container_2_ng_container_1_div_1_Template, 2, 5, "div", 6);
    i0.ɵɵpipe(2, "keyvalue");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(2, 1, ctx_r8.field.formControl.errors));
} }
function DynamicFieldComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, DynamicFieldComponent_ng_container_2_ng_container_1_Template, 3, 3, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.validateOnlyOnSubmit ? ctx_r2.isInvalid() : ctx_r2.field.formControl.invalid && ctx_r2.field.formControl.touched);
} }
class DynamicFieldComponent {
    constructor(navigation, moduleNameMapper, router, dynamicLabelService, linkRouteAsyncActionService, cd) {
        this.navigation = navigation;
        this.moduleNameMapper = moduleNameMapper;
        this.router = router;
        this.dynamicLabelService = dynamicLabelService;
        this.linkRouteAsyncActionService = linkRouteAsyncActionService;
        this.cd = cd;
        this.record = null;
        this.parent = null;
        this.klass = null;
        this.class = 'dynamic-field';
        this.isInvalid = signal(false);
        this.validateOnlyOnSubmit = false;
    }
    get getRelateLink() {
        let linkModule = this.field.definition.module;
        if (this.field.definition.type_name === 'parent_type') {
            linkModule = this.record.attributes.parent_type;
        }
        if (this.field.definition.id_name && linkModule) {
            const moduleName = this.moduleNameMapper.toFrontend(linkModule);
            return this.navigation.getRecordRouterLink(moduleName, this.record.attributes[this.field.definition.id_name]);
        }
        return '';
    }
    ngOnInit() {
        this.setHostClass();
        this.cd.detectChanges();
        this.validateOnlyOnSubmit = this.record?.metadata?.validateOnlyOnSubmit;
        if (this.record?.validationTriggered) {
            this.isInvalid = computed(() => {
                if (this.validateOnlyOnSubmit && this.record?.validationTriggered() && this.field.formControl?.invalid) {
                    return true;
                }
                return false;
            });
        }
    }
    isLink() {
        if (EDITABLE_VIEW_MODES.includes(this.mode)) {
            return false;
        }
        if (!this.field || !this.record) {
            return false;
        }
        if (this.type === 'relate') {
            return true;
        }
        return !!(this?.field?.metadata && this?.field?.metadata?.link);
    }
    hasOnClick() {
        const fieldMetadata = this?.field?.metadata ?? {};
        const linkAsyncAction = fieldMetadata?.linkAsyncAction ?? null;
        const linkOnClick = fieldMetadata?.onClick ?? null;
        return !!(linkAsyncAction || linkOnClick);
    }
    isEdit() {
        return this.mode === 'edit' || this.mode === 'filter';
    }
    getLink() {
        if (this.type === 'relate') {
            return this.getRelateLink;
        }
        const fieldMetadata = this?.field?.metadata ?? null;
        const linkRoute = fieldMetadata.linkRoute ?? null;
        if (fieldMetadata && linkRoute) {
            return this.dynamicLabelService.parse(linkRoute, {}, this.record.fields);
        }
        return this.navigation.getRecordRouterLink(this.record.module, this.record.id);
    }
    getMessageContext(item, record) {
        const context = item && item.message && item.message.context || {};
        context.module = (record && record.module) || '';
        return context;
    }
    getMessageLabelKey(item) {
        return (item && item.message && item.message.labelKey) || '';
    }
    onClick() {
        const fieldMetadata = this?.field?.metadata ?? null;
        if (fieldMetadata && fieldMetadata.onClick) {
            this.field.metadata.onClick(this.field, this.record);
            return;
        }
        const linkAsyncAction = fieldMetadata.linkAsyncAction ?? null;
        if (fieldMetadata && linkAsyncAction) {
            this.linkRouteAsyncActionService.run(linkAsyncAction, this.field, this.record);
            return;
        }
        this.router.navigateByUrl(this.getLink()).then();
        return false;
    }
    setHostClass() {
        const classes = [];
        classes.push('dynamic-field');
        if (this.mode) {
            classes.push('dynamic-field-mode-' + this.mode);
        }
        if (this.type) {
            classes.push('dynamic-field-type-' + this.type);
        }
        if (this.field && this.field.name) {
            classes.push('dynamic-field-name-' + this.field.name);
        }
        this.class = classes.join(' ');
    }
    static { this.ɵfac = function DynamicFieldComponent_Factory(t) { return new (t || DynamicFieldComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(DynamicLabelService), i0.ɵɵdirectiveInject(LinkRouteAsyncActionService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DynamicFieldComponent, selectors: [["scrm-dynamic-field"]], hostVars: 2, hostBindings: function DynamicFieldComponent_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵclassMap(ctx.class);
        } }, inputs: { mode: "mode", originalMode: "originalMode", type: "type", field: "field", record: "record", parent: "parent", klass: "klass", componentType: "componentType" }, decls: 3, vars: 3, consts: [[4, "ngIf"], [1, "clickable", "field-link", 3, "click"], [3, "ndcDynamicComponent", "ndcDynamicInputs"], [1, "field-link", 3, "routerLink", "queryParams"], [1, "dynamic-field"], [1, "flex-grow-1", "text-break", "rounded", "box-loading", "skeleton-field-content"], ["class", "invalid-feedback d-block", 4, "ngFor", "ngForOf"], [1, "invalid-feedback", "d-block"], [3, "context", "fields", "labelKey"]], template: function DynamicFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, DynamicFieldComponent_ng_container_0_Template, 4, 3, "ng-container", 0);
            i0.ɵɵtemplate(1, DynamicFieldComponent_ng_container_1_Template, 3, 0, "ng-container", 0);
            i0.ɵɵtemplate(2, DynamicFieldComponent_ng_container_2_Template, 2, 1, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.field.loading);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.field.loading);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.isEdit() && ctx.field.formControl && ctx.field.formControl.errors);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i1$2.RouterLink, DynamicLabelComponent, i3$3.DynamicIoDirective, i3$3.DynamicComponent, i2.KeyValuePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DynamicFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-dynamic-field', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!field.loading\">\n    <ng-container *ngIf=\"hasOnClick()\">\n        <a (click)=\"onClick()\" class=\"clickable field-link\">\n            <ndc-dynamic\n                [ndcDynamicComponent]=\"componentType\"\n                [ndcDynamicInputs]=\"{\n                'mode': mode,\n                'originalMode': originalMode,\n                'field': field,\n                'klass': klass,\n                'record': record,\n                'parent': parent\n            }\"\n            ></ndc-dynamic>\n        </a>\n    </ng-container>\n    <ng-container *ngIf=\"isLink() && !hasOnClick()\">\n        <a [routerLink]=\"getLink()\" [queryParams]=\"record?.metadata?.queryParams\" class=\"field-link\">\n            <ndc-dynamic\n                [ndcDynamicComponent]=\"componentType\"\n                [ndcDynamicInputs]=\"{\n                'mode': mode,\n                'originalMode': originalMode,\n                'field': field,\n                'klass': klass,\n                'record': record,\n                'parent': parent\n            }\"\n            ></ndc-dynamic>\n        </a>\n    </ng-container>\n    <ng-container *ngIf=\"!isLink() && !hasOnClick()\">\n        <ndc-dynamic\n            [ndcDynamicComponent]=\"componentType\"\n            [ndcDynamicInputs]=\"{\n            'mode': mode,\n            'originalMode': originalMode,\n            'field': field,\n            'klass': klass,\n            'record': record,\n            'parent': parent\n        }\"\n        ></ndc-dynamic>\n    </ng-container>\n</ng-container>\n\n<ng-container *ngIf=\"field.loading\">\n   <div class= \"dynamic-field\">\n        <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"></div>\n   </div>\n</ng-container>\n<ng-container *ngIf=\"isEdit() && field.formControl && field.formControl.errors\">\n    <ng-container *ngIf=\"validateOnlyOnSubmit ? isInvalid() : (field.formControl.invalid && field.formControl.touched)\">\n        <div *ngFor=\"let item of field.formControl.errors | keyvalue\" class=\"invalid-feedback d-block\">\n            <scrm-dynamic-label [context]=\"getMessageContext(item.value, record)\"\n                                [fields]=\"{field: field}\"\n                                [labelKey]=\"getMessageLabelKey(item.value)\">\n            </scrm-dynamic-label>\n        </div>\n    </ng-container>\n</ng-container>\n" }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: i1$2.Router }, { type: DynamicLabelService }, { type: LinkRouteAsyncActionService }, { type: i0.ChangeDetectorRef }]; }, { mode: [{
            type: Input,
            args: ['mode']
        }], originalMode: [{
            type: Input,
            args: ['originalMode']
        }], type: [{
            type: Input,
            args: ['type']
        }], field: [{
            type: Input,
            args: ['field']
        }], record: [{
            type: Input,
            args: ['record']
        }], parent: [{
            type: Input,
            args: ['parent']
        }], klass: [{
            type: Input,
            args: ['klass']
        }], componentType: [{
            type: Input,
            args: ['componentType']
        }], class: [{
            type: HostBinding,
            args: ['class']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$A = ["wrapper"];
function GroupFieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 1);
    i0.ɵɵelementContainerEnd();
} }
function GroupFieldComponent_ng_container_1_ng_container_3_div_1_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8)(1, "label");
    i0.ɵɵelement(2, "scrm-label", 9);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const groupField_r4 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", groupField_r4.labelKey)("module", ctx_r6.getModule());
} }
function GroupFieldComponent_ng_container_1_ng_container_3_div_1_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 10);
    i0.ɵɵelement(1, "scrm-dynamic-field", 11);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const groupField_r4 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("componentType", ctx_r7.getComponentType(groupField_r4.type, groupField_r4.definition))("field", groupField_r4)("klass", ctx_r7.klass)("mode", ctx_r7.mode)("originalMode", ctx_r7.originalMode)("record", ctx_r7.record)("parent", ctx_r7.parent)("type", groupField_r4.type);
} }
function GroupFieldComponent_ng_container_1_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵtemplate(1, GroupFieldComponent_ng_container_1_ng_container_3_div_1_span_1_Template, 3, 2, "span", 6);
    i0.ɵɵtemplate(2, GroupFieldComponent_ng_container_1_ng_container_3_div_1_span_2_Template, 2, 8, "span", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const groupField_r4 = i0.ɵɵnextContext().$implicit;
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("flex-fill", ctx_r5.mode === "edit" && ctx_r5.direction() === "flex-row")("h-100", ctx_r5.direction() === "flex-row");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", groupField_r4.labelKey && ctx_r5.showLabel(groupField_r4.definition.name));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", groupField_r4.type);
} }
function GroupFieldComponent_ng_container_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GroupFieldComponent_ng_container_1_ng_container_3_div_1_Template, 3, 6, "div", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const groupField_r4 = ctx.$implicit;
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.isModeEnabled(ctx_r3.mode, groupField_r4));
} }
function GroupFieldComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", null, 2);
    i0.ɵɵtemplate(3, GroupFieldComponent_ng_container_1_ng_container_3_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("d-flex ", ctx_r1.direction(), " justify-content-start align-items-start field-group h-100 w-100");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r1.getFields());
} }
class GroupFieldComponent extends BaseFieldComponent {
    onResize() {
        this.triggerRecalculateDirection();
    }
    constructor(typeFormatter, registry, logic, logicDisplay, config) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.registry = registry;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
        this.config = config;
        this.direction = signal('');
        this.recalculateDirectionBuffer = new Subject();
        this.recalculateDirectionBuffer$ = this.recalculateDirectionBuffer.asObservable();
    }
    ngOnInit() {
        super.ngOnInit();
        this.subs.push(this.recalculateDirectionBuffer$.pipe(debounceTime(50)).subscribe(() => {
            this.calculateDirection();
        }));
        this.subs.push(this.mode$.subscribe(() => {
            this.triggerRecalculateDirection();
        }));
        this.triggerRecalculateDirection();
        this.hasValidConfig = this.isConfigured();
    }
    ngAfterViewInit() {
        this.triggerRecalculateDirection();
    }
    getComponentType(type, definition) {
        let module = (this.record && this.record.module) || 'default';
        const displayType = (definition && definition.displayType) || '';
        return this.registry.getDisplayType(module, type, displayType, this.mode, this.field.name);
    }
    /**
     * Get the group fields from the record
     *
     * @returns {object} Field[]
     */
    getFields() {
        const fields = [];
        this.field.definition.layout.forEach(name => {
            if (!this.record.fields[name] || this.record.fields[name].display === 'none') {
                return;
            }
            fields.push(this.record.fields[name]);
        });
        return fields;
    }
    getModule() {
        if (!this.record) {
            return null;
        }
        return this.record.module;
    }
    /**
     * Get flex direction to be used
     */
    calculateDirection() {
        const wrapperWidth = this?.wrapper?.nativeElement?.offsetWidth ?? null;
        let direction = 'flex-column';
        if ((this?.field?.definition?.display ?? '') === 'inline') {
            direction = 'flex-row';
        }
        if (!wrapperWidth || this.mode === 'detail' || this.mode === 'list') {
            this.direction.set(direction);
            return;
        }
        const breakpoint = this?.config?.getUi('group_field_mobile_breakdown_limit') ?? 350;
        if (wrapperWidth < breakpoint) {
            this.direction.set('flex-column');
            return;
        }
        this.direction.set(direction);
    }
    /**
     * Check if is configured
     *
     * @returns {boolean} is configured
     */
    isConfigured() {
        return this.hasDisplay() && this.hasLayout() && this.hasGroupFields();
    }
    showLabel(fieldName) {
        const definition = this.field.definition || null;
        const showLabel = definition.showLabel || null;
        if (!definition || !showLabel) {
            return false;
        }
        const showLabelOptions = definition.showLabel[this.mode] || null;
        // showLabel > viewMode not defined || defined without any values e.g. edit:
        if (!showLabelOptions || typeof (showLabelOptions) === 'undefined') {
            return false;
        }
        return (showLabelOptions.includes('*') || showLabelOptions.includes(fieldName));
    }
    isModeEnabled(mode, groupField) {
        const modes = groupField.definition.modes;
        if (!modes || modes.length < 1) {
            return true;
        }
        return modes.includes(mode);
    }
    /**
     * Add re-calculation trigger to buffer
     * @protected
     */
    triggerRecalculateDirection() {
        this.recalculateDirectionBuffer.next(true);
    }
    /**
     * Check if groupFields are configured
     *
     * @returns {boolean} has groupFields
     */
    hasGroupFields() {
        return !!(this.field.definition.groupFields && Object.keys(this.field.definition.groupFields).length);
    }
    /**
     * Check if layout is configured
     *
     * @returns {boolean} has layout
     */
    hasLayout() {
        return !!(this.field.definition.layout && this.field.definition.layout.length);
    }
    /**
     * Check if display is configured
     *
     * @returns {boolean} has display
     */
    hasDisplay() {
        return !!this.field.definition.display;
    }
    static { this.ɵfac = function GroupFieldComponent_Factory(t) { return new (t || GroupFieldComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(StandardFieldRegistry), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GroupFieldComponent, selectors: [["scrm-group-field"]], viewQuery: function GroupFieldComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$A, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.wrapper = _t.first);
        } }, hostBindings: function GroupFieldComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("resize", function GroupFieldComponent_resize_HostBindingHandler($event) { return ctx.onResize($event); }, false, i0.ɵɵresolveWindow);
        } }, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [[4, "ngIf"], ["labelKey", "LBL_BAD_GROUP_FIELD_CONFIG"], ["wrapper", ""], [4, "ngFor", "ngForOf"], ["class", "field-group-item d-flex flex-column justify-content-end w-100", 3, "flex-fill", "h-100", 4, "ngIf"], [1, "field-group-item", "d-flex", "flex-column", "justify-content-end", "w-100"], ["class", "field-group-label pt-2 pr-1", 4, "ngIf"], ["class", "field-group-field pr-1", 4, "ngIf"], [1, "field-group-label", "pt-2", "pr-1"], [3, "labelKey", "module"], [1, "field-group-field", "pr-1"], [3, "componentType", "field", "klass", "mode", "originalMode", "record", "parent", "type"]], template: function GroupFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, GroupFieldComponent_ng_container_0_Template, 2, 0, "ng-container", 0);
            i0.ɵɵtemplate(1, GroupFieldComponent_ng_container_1_Template, 4, 4, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.hasValidConfig);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.hasValidConfig);
        } }, dependencies: [i2.NgForOf, i2.NgIf, LabelComponent, DynamicFieldComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupFieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-group-field', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!this.hasValidConfig\">\n    <scrm-label labelKey=\"LBL_BAD_GROUP_FIELD_CONFIG\"></scrm-label>\n</ng-container>\n\n<ng-container *ngIf=\"this.hasValidConfig\">\n    <div #wrapper class=\"d-flex {{direction()}} justify-content-start align-items-start field-group h-100 w-100\">\n\n        <ng-container *ngFor=\"let groupField of getFields()\">\n\n            <div *ngIf=\"isModeEnabled(mode, groupField)\"\n                 [class.flex-fill]=\"mode ==='edit' && direction() === 'flex-row'\"\n                 class=\"field-group-item d-flex flex-column justify-content-end w-100\"\n                 [class.h-100]=\"direction() === 'flex-row'\">\n\n                <!-- LABEL -->\n                <span *ngIf=\"groupField.labelKey && showLabel(groupField.definition.name)\"\n                      class=\"field-group-label pt-2 pr-1\">\n                    <label>\n                        <scrm-label [labelKey]=\"groupField.labelKey\" [module]=\"getModule()\"></scrm-label>\n                    </label>\n                </span>\n\n                <!-- VALUE -->\n                <span *ngIf=\"groupField.type\" class=\"field-group-field pr-1\">\n\n                    <scrm-dynamic-field [componentType]=\"getComponentType(groupField.type, groupField.definition)\"\n                                        [field]=\"groupField\"\n                                        [klass]=\"klass\"\n                                        [mode]=\"mode\"\n                                        [originalMode]=\"originalMode\"\n                                        [record]=\"record\"\n                                        [parent]=\"parent\"\n                                        [type]=\"groupField.type\">\n                    </scrm-dynamic-field>\n\n                </span>\n            </div>\n        </ng-container>\n\n    </div>\n</ng-container>\n\n\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: StandardFieldRegistry }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }, { type: SystemConfigStore }]; }, { wrapper: [{
            type: ViewChild,
            args: ['wrapper']
        }], onResize: [{
            type: HostListener,
            args: ['window:resize', ['$event']]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DynamicFieldModule {
    static { this.ɵfac = function DynamicFieldModule_Factory(t) { return new (t || DynamicFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: DynamicFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            RouterModule,
            DynamicLabelModule,
            DynamicModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DynamicFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [DynamicFieldComponent],
                exports: [
                    DynamicFieldComponent
                ],
                imports: [
                    CommonModule,
                    RouterModule,
                    DynamicLabelModule,
                    DynamicModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(DynamicFieldModule, { declarations: [DynamicFieldComponent], imports: [CommonModule,
        RouterModule,
        DynamicLabelModule,
        DynamicModule], exports: [DynamicFieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GroupFieldModule {
    static { this.ɵfac = function GroupFieldModule_Factory(t) { return new (t || GroupFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GroupFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule,
            DynamicFieldModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupFieldModule, [{
        type: NgModule,
        args: [{
                declarations: [GroupFieldComponent],
                imports: [
                    CommonModule,
                    LabelModule,
                    DynamicFieldModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(GroupFieldModule, { declarations: [GroupFieldComponent], imports: [CommonModule,
        LabelModule,
        DynamicFieldModule] }); })();

const currencyValidator = (formatter) => ((control) => {
    const invalid = formatter.validateFloatUserFormat(control.value);
    return invalid ? {
        currencyValidator: {
            valid: false,
            format: formatter.getFloatUserFormatPattern(),
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_CURRENCY_FORMAT',
                context: {
                    value: control.value,
                    expected: formatter.toUserFormat('1000.50')
                }
            }
        },
    } : null;
});
class CurrencyValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'currency';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        return [currencyValidator(this.formatter)];
    }
    static { this.ɵfac = function CurrencyValidator_Factory(t) { return new (t || CurrencyValidator)(i0.ɵɵinject(NumberFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CurrencyValidator, factory: CurrencyValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: NumberFormatter }]; }, null); })();

const dateValidator = (formatter, userFormat) => ((control) => {
    const invalid = formatter.validateUserFormat(control.value, userFormat);
    return invalid ? {
        invalidDate: {
            value: control.value,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_DATE_FORMAT',
                context: {
                    value: control.value,
                    expected: formatter.toUserFormat('2020-01-23')
                }
            }
        },
    } : null;
});
class DateValidator {
    constructor(formatter, utils) {
        this.formatter = formatter;
        this.utils = utils;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'date';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        let userFormat = viewField?.metadata?.date_time_format || '';
        return [dateValidator(this.formatter, userFormat)];
    }
    static { this.ɵfac = function DateValidator_Factory(t) { return new (t || DateValidator)(i0.ɵɵinject(DateFormatter), i0.ɵɵinject(FormControlUtils)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateValidator, factory: DateValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DateFormatter }, { type: FormControlUtils }]; }, null); })();

const dateTimeValidator = (formatter, userFormat) => ((control) => {
    const invalid = formatter.validateUserFormat(control.value, userFormat);
    return invalid ? {
        dateTimeValidator: {
            value: control.value,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_DATETIME_FORMAT',
                context: {
                    value: control.value,
                    expected: formatter.toUserFormat('2020-01-23 12:30:40')
                }
            }
        },
    } : null;
});
class DateTimeValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'datetime';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        const userFormat = viewField?.metadata?.date_time_format || '';
        return [dateTimeValidator(this.formatter, userFormat)];
    }
    static { this.ɵfac = function DateTimeValidator_Factory(t) { return new (t || DateTimeValidator)(i0.ɵɵinject(DatetimeFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DateTimeValidator, factory: DateTimeValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DatetimeFormatter }]; }, null); })();

const floatValidator = (formatter) => ((control) => {
    const invalid = formatter.validateFloatUserFormat(control.value);
    return invalid ? {
        floatValidator: {
            valid: false,
            format: formatter.getFloatUserFormatPattern(),
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_FLOAT_FORMAT',
                context: {
                    value: control.value,
                    expected: formatter.toUserFormat('1000.50')
                }
            }
        },
    } : null;
});
class FloatValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'float';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        return [floatValidator(this.formatter)];
    }
    static { this.ɵfac = function FloatValidator_Factory(t) { return new (t || FloatValidator)(i0.ɵɵinject(NumberFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FloatValidator, factory: FloatValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FloatValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: NumberFormatter }]; }, null); })();

const intValidator = (formatter) => ((control) => {
    const invalid = formatter.validateIntUserFormat(control.value);
    return invalid ? {
        intValidator: {
            valid: false,
            format: formatter.getIntUserFormatPattern(),
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_INT_FORMAT',
                context: {
                    value: control.value,
                    expected: formatter.toUserFormat('1000')
                }
            }
        },
    } : null;
});
class IntValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        return (viewField?.type ?? viewField?.fieldDefinition?.type) === 'int';
    }
    getValidator(viewField) {
        if (!(viewField?.type ?? viewField?.fieldDefinition?.type)) {
            return [];
        }
        return [intValidator(this.formatter)];
    }
    static { this.ɵfac = function IntValidator_Factory(t) { return new (t || IntValidator)(i0.ɵɵinject(NumberFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: IntValidator, factory: IntValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IntValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: NumberFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EmailFormatter {
    constructor(formUtils, configs) {
        this.formUtils = formUtils;
        this.configs = configs;
    }
    toUserFormat(value) {
        return value;
    }
    toInternalFormat(value) {
        return value;
    }
    getUserFormatPattern() {
        const validations = this.configs.getUi('validations');
        let defaultRegex = validations?.regex?.email || '';
        if (!defaultRegex) {
            // eslint-disable-next-line max-len
            defaultRegex = "^(?:[\\.\\-\\+&#!\\$\\*=\\?\\^_`\\{\\}~\\/\\w]+)@(?:(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|\\w+(?:[\\.-]*\\w+)*(?:\\.[\\w-]{2,})+)$";
        }
        return defaultRegex;
    }
    validateUserFormat(inputValue, validationRegexPattern = '') {
        const trimmedInputValue = this.formUtils.getTrimmedInputValue(inputValue);
        if (this.formUtils.isEmptyInputValue(trimmedInputValue)) {
            return false;
        }
        const regex = new RegExp(validationRegexPattern);
        return !regex.test(trimmedInputValue);
    }
    static { this.ɵfac = function EmailFormatter_Factory(t) { return new (t || EmailFormatter)(i0.ɵɵinject(FormControlUtils), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: EmailFormatter, factory: EmailFormatter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailFormatter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FormControlUtils }, { type: SystemConfigStore }]; }, null); })();

const emailValidator = (formatter, customValidationRegex) => ((control) => {
    const validationRegex = customValidationRegex || formatter.getUserFormatPattern();
    const invalid = formatter.validateUserFormat(control.value, validationRegex);
    return invalid ? {
        emailValidator: {
            valid: false,
            format: new RegExp(validationRegex),
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_EMAIL_FORMAT',
                context: {
                    value: control.value,
                    expected: 'example@example.org'
                }
            }
        },
    } : null;
});
class EmailValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'email';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        const customValidationRegex = viewField?.fieldDefinition?.validation?.regex.toString() ?? null;
        return [emailValidator(this.formatter, customValidationRegex)];
    }
    static { this.ɵfac = function EmailValidator_Factory(t) { return new (t || EmailValidator)(i0.ɵɵinject(EmailFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: EmailValidator, factory: EmailValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: EmailFormatter }]; }, null); })();

const phoneValidator = (formatter, customRegex) => ((control) => {
    const regexPattern = customRegex || formatter.getDefaultFormatPattern();
    const invalid = formatter.validateUserFormat(control.value, regexPattern);
    return invalid ? {
        phoneValidator: {
            valid: false,
            format: regexPattern,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_PHONE_FORMAT',
                context: {
                    value: control.value
                }
            }
        },
    } : null;
});
class PhoneValidator {
    constructor(formatter) {
        this.formatter = formatter;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        return viewField.type === 'phone';
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        const customRegex = viewField?.fieldDefinition?.validation?.regex.toString() ?? null;
        return [phoneValidator(this.formatter, customRegex)];
    }
    static { this.ɵfac = function PhoneValidator_Factory(t) { return new (t || PhoneValidator)(i0.ɵɵinject(PhoneFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PhoneValidator, factory: PhoneValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PhoneValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: PhoneFormatter }]; }, null); })();

const minValidator = (min) => ((control) => {
    const result = Validators.min(min)(control);
    if (result === null) {
        return null;
    }
    return {
        emailValidator: {
            ...result,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_MIN',
                context: {
                    value: control.value,
                    min: '' + min
                }
            }
        }
    };
});
const maxValidator = (max) => ((control) => {
    const result = Validators.max(max)(control);
    if (result === null) {
        return null;
    }
    return {
        emailValidator: {
            ...result,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_MAX',
                context: {
                    value: control.value,
                    max: '' + max
                }
            }
        }
    };
});
class RangeValidator {
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        const definition = viewField.fieldDefinition;
        return this.getRangeValidation(definition) !== null;
    }
    getValidator(viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return [];
        }
        const validation = this.getRangeValidation(viewField.fieldDefinition);
        if (!validation) {
            return [];
        }
        let max = null;
        if (isNumber(validation?.max)) {
            max = parseInt('' + validation.max, 10);
        }
        let min = null;
        if (isNumber(validation?.min)) {
            min = parseInt('' + validation.min, 10);
        }
        const validations = [];
        if (isNumber(min) && isFinite(min)) {
            validations.push(minValidator(min));
        }
        if (isNumber(max) && isFinite(max)) {
            validations.push(maxValidator(max));
        }
        return validations;
    }
    getRangeValidation(definition) {
        if (this.isRangeValidation(definition.validation)) {
            return definition.validation;
        }
        if (!definition.validations || !definition.validations.length) {
            return null;
        }
        let validation = null;
        definition.validations.some(entry => {
            validation = entry;
            return this.isRangeValidation(entry);
        });
        return validation;
    }
    isRangeValidation(validation) {
        return validation && validation.type === 'range';
    }
    static { this.ɵfac = function RangeValidator_Factory(t) { return new (t || RangeValidator)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RangeValidator, factory: RangeValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RangeValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

const primaryEmailValidator = (viewField, record) => ((control) => {
    const name = viewField.name || '';
    if (!name || !record || !record.fields) {
        return null;
    }
    const field = record.fields[name] || {};
    const items = field.items;
    if (!field || !items || !items.length) {
        return null;
    }
    let count = 0;
    const activeItems = items.filter(item => !(item && item.attributes && item.attributes.deleted));
    if (activeItems && activeItems.length < 1) {
        return null;
    }
    let nonEmpty = 0;
    activeItems.some(item => {
        const emailField = (item.fields && item.fields['email-fields']) || {};
        const primary = (emailField.attributes && emailField.attributes['primary_address']) || null;
        const emailAddress = (emailField.attributes && emailField.attributes['email_address']) || null;
        if (!emailAddress?.value) {
            return false;
        }
        nonEmpty++;
        if (!primary) {
            return false;
        }
        if (isTrue(primary.value)) {
            count++;
        }
        return count > 1;
    });
    if (count == 1) {
        return null;
    }
    if (count == 0 && nonEmpty === 0) {
        return null;
    }
    if (count == 0) {
        return {
            primaryEmailValidation: {
                valid: false,
                message: {
                    labelKey: 'LBL_NO_PRIMARY_EMAIL_VALIDATION_ERROR',
                    context: {}
                }
            },
        };
    }
    return {
        primaryEmailValidation: {
            valid: false,
            message: {
                labelKey: 'LBL_MULTIPLE_PRIMARY_EMAIL_VALIDATION_ERROR',
                context: {}
            }
        },
    };
});
class PrimaryEmailValidator {
    constructor() {
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        const type = viewField.type || viewField.fieldDefinition.type || '';
        const name = viewField.name || viewField.fieldDefinition.name || '';
        return type === 'line-items' && name === 'email_addresses';
    }
    getValidator(viewField, record) {
        if (!viewField || !viewField.fieldDefinition || !record) {
            return [];
        }
        return [primaryEmailValidator(viewField, record)];
    }
    static { this.ɵfac = function PrimaryEmailValidator_Factory(t) { return new (t || PrimaryEmailValidator)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PrimaryEmailValidator, factory: PrimaryEmailValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PrimaryEmailValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

const duplicateEmailValidator = (viewField, record) => ((control) => {
    const name = viewField.name || '';
    if (!name || !record || !record.fields) {
        return null;
    }
    const field = record.fields[name] || {};
    const items = field.items;
    if (!field || !items || !items.length) {
        return null;
    }
    const addresses = {};
    let count = 0;
    const activeItems = items.filter(item => !(item && item.attributes && item.attributes.deleted));
    if (activeItems && activeItems.length < 1) {
        return null;
    }
    activeItems.some(item => {
        const emailField = (item.fields && item.fields['email-fields']) || {};
        const emailAddress = (emailField.attributes && emailField.attributes['email_address']) || null;
        if (!emailAddress.value) {
            return false;
        }
        const upperCaseValue = ("" + emailAddress.value).toUpperCase();
        if (addresses[upperCaseValue]) {
            count++;
            return true;
        }
        addresses[upperCaseValue] = true;
        return count > 1;
    });
    if (count == 0) {
        return null;
    }
    return {
        duplicateEmailValidation: {
            valid: false,
            message: {
                labelKey: 'LBL_DUPLICATE_EMAIL_VALIDATION_ERROR',
                context: {}
            }
        },
    };
});
class DuplicateEmailValidator {
    constructor() {
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        const type = viewField.type || viewField.fieldDefinition.type || '';
        const name = viewField.name || viewField.fieldDefinition.name || '';
        return type === 'line-items' && name === 'email_addresses';
    }
    getValidator(viewField, record) {
        if (!viewField || !viewField.fieldDefinition || !record) {
            return [];
        }
        return [duplicateEmailValidator(viewField, record)];
    }
    static { this.ɵfac = function DuplicateEmailValidator_Factory(t) { return new (t || DuplicateEmailValidator)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DuplicateEmailValidator, factory: DuplicateEmailValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DuplicateEmailValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

const lineItemsRequiredValidator = (viewField, record, utils) => ((control) => {
    const name = viewField.name || '';
    if (!name || !record || !record.fields) {
        return null;
    }
    const field = record?.fields[name] ?? {};
    const items = field?.items ?? [];
    if (!field || !items) {
        return null;
    }
    const activeItems = items.filter(item => !(item && item.attributes && item.attributes.deleted));
    if (activeItems && activeItems.length > 0) {
        return null;
    }
    return {
        required: {
            required: true,
            message: {
                labelKey: 'LBL_VALIDATION_ERROR_REQUIRED',
                context: {}
            }
        }
    };
});
class LineItemsRequiredValidator {
    constructor(utils) {
        this.utils = utils;
    }
    applies(record, viewField) {
        if (!viewField || !viewField.fieldDefinition) {
            return false;
        }
        const type = viewField?.type ?? viewField?.fieldDefinition?.type ?? '';
        let required = viewField?.required ?? viewField?.fieldDefinition?.required ?? false;
        return type === 'line-items' && isTrue(required);
    }
    getValidator(viewField, record) {
        return [lineItemsRequiredValidator(viewField, record, this.utils)];
    }
    static { this.ɵfac = function LineItemsRequiredValidator_Factory(t) { return new (t || LineItemsRequiredValidator)(i0.ɵɵinject(FormControlUtils)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LineItemsRequiredValidator, factory: LineItemsRequiredValidator.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineItemsRequiredValidator, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FormControlUtils }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ValidationManager {
    constructor(requiredValidator, rangeValidator, currencyValidator, dateValidator, datetimeValidator, emailValidator, floatValidator, intValidator, phoneValidator, primaryEmailValidator, duplicateEmailValidator, lineItemsRequiredValidator) {
        this.requiredValidator = requiredValidator;
        this.rangeValidator = rangeValidator;
        this.currencyValidator = currencyValidator;
        this.dateValidator = dateValidator;
        this.datetimeValidator = datetimeValidator;
        this.emailValidator = emailValidator;
        this.floatValidator = floatValidator;
        this.intValidator = intValidator;
        this.phoneValidator = phoneValidator;
        this.primaryEmailValidator = primaryEmailValidator;
        this.duplicateEmailValidator = duplicateEmailValidator;
        this.lineItemsRequiredValidator = lineItemsRequiredValidator;
        this.filterFieldExclusion = {
            default: {}
        };
        this.saveFieldExclusions = {
            default: {}
        };
        this.saveValidators = new OverridableMap();
        this.itemFormArraySaveValidators = new OverridableMap();
        this.asyncSaveValidators = new OverridableMap();
        this.filterValidators = new OverridableMap();
        this.saveValidators.addEntry('default', this.getKey('required', 'all'), requiredValidator);
        this.saveValidators.addEntry('default', this.getKey('range', 'all'), rangeValidator);
        this.saveValidators.addEntry('default', this.getKey('currency', 'all'), currencyValidator);
        this.saveValidators.addEntry('default', this.getKey('date', 'all'), dateValidator);
        this.saveValidators.addEntry('default', this.getKey('datetime', 'all'), datetimeValidator);
        this.saveValidators.addEntry('default', this.getKey('email', 'all'), emailValidator);
        this.saveValidators.addEntry('default', this.getKey('float', 'all'), floatValidator);
        this.saveValidators.addEntry('default', this.getKey('int', 'all'), intValidator);
        this.saveValidators.addEntry('default', this.getKey('phone', 'all'), phoneValidator);
        this.itemFormArraySaveValidators.addEntry('default', this.getKey('primary-email', 'all'), primaryEmailValidator);
        this.itemFormArraySaveValidators.addEntry('default', this.getKey('duplicate-email', 'all'), duplicateEmailValidator);
        this.itemFormArraySaveValidators.addEntry('default', this.getKey('line-items-required', 'all'), lineItemsRequiredValidator);
        this.filterValidators.addEntry('default', this.getKey('date', 'all'), dateValidator);
        this.filterValidators.addEntry('default', this.getKey('datetime', 'all'), datetimeValidator);
        this.filterValidators.addEntry('default', this.getKey('float', 'all'), floatValidator);
        this.filterValidators.addEntry('default', this.getKey('currency', 'all'), currencyValidator);
        this.filterValidators.addEntry('default', this.getKey('int', 'all'), intValidator);
        this.filterValidators.addEntry('default', this.getKey('phone', 'all'), phoneValidator);
    }
    registerFieldSaveValidator(module, type, field, validator) {
        this.saveValidators.addEntry(module, this.getKey(type, field), validator);
    }
    registerSaveValidator(module, type, validator) {
        this.saveValidators.addEntry(module, this.getKey(type, 'all'), validator);
    }
    registerFieldFilterValidator(module, type, field, validator) {
        this.filterValidators.addEntry(module, this.getKey(type, field), validator);
    }
    registerFilterValidator(module, type, validator) {
        this.filterValidators.addEntry(module, this.getKey(type, 'all'), validator);
    }
    excludeFieldSaveValidator(module, type, field) {
        const moduleExclusions = this.saveFieldExclusions[module] || {};
        const key = this.getKey(type, field);
        moduleExclusions[key] = key;
        this.saveFieldExclusions[module] = moduleExclusions;
    }
    excludeSaveValidator(module, type) {
        this.saveValidators.excludeEntry(module, this.getKey(type, 'all'));
    }
    excludeFieldFilterValidator(module, type, field) {
        const moduleExclusions = this.filterFieldExclusion[module] || {};
        const key = this.getKey(type, field);
        moduleExclusions[key] = key;
        this.filterFieldExclusion[module] = moduleExclusions;
    }
    excludeFilterValidator(module, type) {
        this.filterValidators.excludeEntry(module, this.getKey(type, 'all'));
    }
    registerAsyncSaveValidator(module, type, validator) {
        this.asyncSaveValidators.addEntry(module, this.getKey(type, 'all'), validator);
    }
    excludeAsyncSaveValidator(module, type) {
        this.saveValidators.excludeEntry(module, this.getKey(type, 'all'));
    }
    getSaveValidations(module, viewField, record) {
        const entries = this.saveValidators.getGroupEntries(module);
        const exclusions = this.getExclusions(module, this.saveFieldExclusions);
        return this.filterValidations(entries, exclusions, record, viewField);
    }
    getItemFormArraySaveValidations(module, viewField, record) {
        const entries = this.itemFormArraySaveValidators.getGroupEntries(module);
        const exclusions = this.getExclusions(module, this.saveFieldExclusions);
        return this.filterValidations(entries, exclusions, record, viewField);
    }
    getFilterValidations(module, viewField, record) {
        const entries = this.filterValidators.getGroupEntries(module);
        const exclusions = this.getExclusions(module, this.filterFieldExclusion);
        return this.filterValidations(entries, exclusions, record, viewField);
    }
    getAsyncSaveValidations(module, viewField, record) {
        const validations = [];
        const entries = this.asyncSaveValidators.getGroupEntries(module);
        Object.keys(entries).forEach(validatorKey => {
            const validator = entries[validatorKey];
            if (validator.applies(record, viewField)) {
                validations.push(validator.getValidator(viewField, record));
            }
        });
        return validations;
    }
    getKey(type, field) {
        return `${type}.${field}`;
    }
    parseType(key) {
        const partsType = key.split('.') || [];
        return partsType[0] || '';
    }
    getExclusions(module, exclusionMap) {
        const defaultExclusions = exclusionMap['default'] || {};
        const moduleExclusions = exclusionMap[module] || {};
        return { ...defaultExclusions, ...moduleExclusions };
    }
    filterValidations(entries, fieldExclusions, record, viewField) {
        let validations = [];
        Object.keys(entries).forEach(validatorKey => {
            const defaultTypeKey = this.getKey(this.parseType(validatorKey), viewField.name);
            if (fieldExclusions[validatorKey] || fieldExclusions[defaultTypeKey]) {
                return;
            }
            const validator = entries[validatorKey];
            if (validator.applies(record, viewField)) {
                validations = validations.concat(validator.getValidator(viewField, record));
            }
        });
        return validations;
    }
    static { this.ɵfac = function ValidationManager_Factory(t) { return new (t || ValidationManager)(i0.ɵɵinject(RequiredValidator), i0.ɵɵinject(RangeValidator), i0.ɵɵinject(CurrencyValidator), i0.ɵɵinject(DateValidator), i0.ɵɵinject(DateTimeValidator), i0.ɵɵinject(EmailValidator), i0.ɵɵinject(FloatValidator), i0.ɵɵinject(IntValidator), i0.ɵɵinject(PhoneValidator), i0.ɵɵinject(PrimaryEmailValidator), i0.ɵɵinject(DuplicateEmailValidator), i0.ɵɵinject(LineItemsRequiredValidator)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ValidationManager, factory: ValidationManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ValidationManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: RequiredValidator }, { type: RangeValidator }, { type: CurrencyValidator }, { type: DateValidator }, { type: DateTimeValidator }, { type: EmailValidator }, { type: FloatValidator }, { type: IntValidator }, { type: PhoneValidator }, { type: PrimaryEmailValidator }, { type: DuplicateEmailValidator }, { type: LineItemsRequiredValidator }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MultiEnumField extends BaseField {
    get value() {
        return this.valueListState.join(',');
    }
    set value(value) {
        this.valueState = '';
        this.valueListState = [];
        if (isArray(value) && isString(value[0])) {
            this.valueList = value;
            return;
        }
        if (!value) {
            return;
        }
        this.emitValueChanges();
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const baseObjectFieldsTypeMap = {
    'default': BaseField,
    'multienum': MultiEnumField
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldObjectRegistry extends BaseTypeRegistry {
    initDefault() {
        Object.keys(this.getDefaultMap()).forEach(type => {
            this.register('default', type, this.getDefaultMap()[type]);
        });
    }
    getDefaultMap() {
        return baseObjectFieldsTypeMap;
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵFieldObjectRegistry_BaseFactory; return function FieldObjectRegistry_Factory(t) { return (ɵFieldObjectRegistry_BaseFactory || (ɵFieldObjectRegistry_BaseFactory = i0.ɵɵgetInheritedFactory(FieldObjectRegistry)))(t || FieldObjectRegistry); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldObjectRegistry, factory: FieldObjectRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldObjectRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Build field
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object}Field
     */
    buildField(record, viewField, language = null) {
        const module = record?.module ?? '';
        let definition = viewField?.fieldDefinition ?? {};
        const multiModuleDefinitions = viewField?.multiModuleDefinitions ?? {};
        const currentModuleDefinitions = multiModuleDefinitions[module] ?? {};
        if (!isEmpty(currentModuleDefinitions)) {
            definition = currentModuleDefinitions;
        }
        const { value, valueList, valueObject } = this.parseValue(viewField, definition, record);
        const { validators, asyncValidators, itemFormArraySaveValidators } = this.getSaveValidators(record, viewField);
        const field = this.setupField(record.module, viewField, value, valueList, valueObject, record, definition, validators, asyncValidators, language);
        field.itemFormArraySaveValidators = itemFormArraySaveValidators;
        return field;
    }
    getFieldLabel(label, module, language) {
        const languages = language.getLanguageStrings();
        return language.getFieldLabel(label, module, languages);
    }
    /**
     * Parse value from record
     *
     * @param {object} viewField ViewFieldDefinition
     * @param {object} definition FieldDefinition
     * @param {object} record Record
     * @returns {object} value object
     */
    parseValue(viewField, definition, record) {
        const type = (viewField && viewField.type) || '';
        const source = (definition && definition.source) || '';
        const rname = (definition && definition.rname) || 'name';
        const viewName = viewField.name || '';
        let value = null;
        let valueList = null;
        if (!viewName || (!record.attributes[viewName] && !isFalse(record.attributes[viewName]))) {
            value = '';
        }
        else if (type === 'relate' && source === 'non-db' && rname !== '') {
            value = record.attributes[viewName][rname];
            const valueObject = record.attributes[viewName];
            return { value, valueList, valueObject };
        }
        else {
            value = record.attributes[viewName];
        }
        if (type === 'line-items') {
            return { value: null, valueList };
        }
        if (Array.isArray(value)) {
            valueList = value;
            value = null;
        }
        return { value, valueList };
    }
    /**
     * Build and initialize field object
     *
     * @param {string} module to use
     * @param {object} viewField ViewFieldDefinition
     * @param {string} value string
     * @param {[]} valueList string[]
     * @param {} valueObject value object
     * @param {object} record Record
     * @param {object} definition FieldDefinition
     * @param {[]} validators ValidatorFn[]
     * @param {[]} asyncValidators AsyncValidatorFn[]
     * @param {object} language LanguageStore
     * @returns {object} BaseField
     */
    setupField(module, viewField, value, valueList, valueObject, record, definition, validators, asyncValidators, language) {
        const metadata = merge$1(definition?.metadata ?? {}, viewField?.metadata ?? {});
        const formattedValue = this.typeFormatter.toUserFormat(viewField.type, value, { mode: 'edit', metadata });
        if (viewField.link) {
            metadata.link = viewField.link;
        }
        const type = viewField.type || definition.type;
        const FieldObjectType = this.fieldRegistry.get(module, type);
        const field = new FieldObjectType();
        field.type = type;
        field.name = viewField.name || definition.name || '';
        field.vardefBased = viewField?.vardefBased ?? definition?.vardefBased ?? false;
        field.readonly = isTrue(viewField.readonly) || isTrue(definition.readonly) || false;
        field.display = (viewField.display || definition.display || 'default');
        field.defaultDisplay = field.display;
        if (field.defaultDisplay === 'default') {
            field.defaultDisplay = 'show';
        }
        field.value = value;
        field.metadata = metadata;
        field.definition = definition;
        if (viewField?.lineItems) {
            field.definition.lineItems = viewField.lineItems;
        }
        field.labelKey = viewField.label || definition.vname || '';
        field.dynamicLabelKey = viewField.dynamicLabelKey || definition.dynamicLabelKey || '';
        const defaultValue = viewField?.defaultValue ?? definition?.default ?? definition?.defaultValue ?? null;
        if (defaultValue) {
            field.default = defaultValue;
        }
        field.defaultValueModes = viewField?.defaultValueModes ?? definition?.defaultValueModes ?? [];
        field.validators = validators;
        field.asyncValidators = asyncValidators;
        if (field.type === 'line-items') {
            field.valueObjectArray = record.attributes[field.name];
            field.itemFormArray = new UntypedFormArray([]);
            field.formControl = new UntypedFormControl(formattedValue);
        }
        else {
            field.formControl = new UntypedFormControl(formattedValue);
        }
        field.attributes = {};
        field.source = 'field';
        field.logic = viewField.logic || definition.logic || null;
        field.displayLogic = viewField.displayLogic || definition.displayLogic || null;
        const fieldDependencies = {};
        const attributeDependencies = {};
        this.addFieldDependencies(field.logic, fieldDependencies, attributeDependencies, 'logic');
        this.addFieldDependencies(field.displayLogic, fieldDependencies, attributeDependencies, 'displayLogic');
        field.attributeDependencies = Object.keys(attributeDependencies).map(key => attributeDependencies[key]);
        field.fieldDependencies = fieldDependencies;
        if (valueList) {
            field.valueList = valueList;
        }
        if (valueObject) {
            field.valueObject = valueObject;
        }
        if (language) {
            field.label = this.getFieldLabel(viewField.label, module, language);
        }
        if (!field.labelKey && viewField.label) {
            field.labelKey = viewField.label;
        }
        return field;
    }
    addFieldDependencies(config, fieldDependencies, attributeDependencies, type) {
        if (config && Object.keys(config).length) {
            Object.keys(config).forEach(logicKey => {
                const entry = config[logicKey] || {};
                if (!entry.params) {
                    return;
                }
                if (entry.params && entry.params.attributeDependencies) {
                    entry.params.attributeDependencies.forEach(dependency => {
                        const dependencyKey = dependency.field + '.' + dependency.attribute;
                        attributeDependencies[dependencyKey] = dependency;
                    });
                }
                if (entry.params && entry.params.fieldDependencies) {
                    entry.params.fieldDependencies.forEach(dependency => {
                        const fieldDependency = fieldDependencies[dependency] ?? {};
                        const types = fieldDependency['types'] ?? [];
                        types.push(type);
                        fieldDependencies[dependency] = {
                            field: dependency,
                            type: types
                        };
                    });
                }
            });
        }
    }
    /**
     * Get save validators for the given field definition
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @returns {object} Validator map
     */
    getSaveValidators(record, viewField) {
        const validators = this.validationManager.getSaveValidations(record.module, viewField, record);
        const asyncValidators = this.validationManager.getAsyncSaveValidations(record.module, viewField, record);
        const itemFormArraySaveValidators = this.validationManager.getItemFormArraySaveValidations(record.module, viewField, record);
        return { validators, asyncValidators, itemFormArraySaveValidators };
    }
    /**
     * Set attribute value on parent
     *
     * @param {object} record Record
     * @param {object} field Field
     * @param {string} name String
     * @param {object} definition FieldDefinition
     * @returns any
     */
    getParentValue(record, field, name, definition) {
        const valueParent = definition.valueParent ?? 'field';
        const parent = valueParent === 'record' ? record : field;
        if (definition.valuePath) {
            return get(parent, definition.valuePath, '');
        }
        if (valueParent === 'record') {
            return get(record.attributes, name, '');
        }
        return get(field.valueObject, name, '');
    }
    static { this.ɵfac = function FieldBuilder_Factory(t) { return new (t || FieldBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldBuilder, factory: FieldBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GroupFieldBuilder extends FieldBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        super(validationManager, typeFormatter, fieldRegistry);
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Create and add group fields to record
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @param {function} isInitializedFunction
     * @param {function} buildFieldFunction
     * @param {function} addRecordFunction
     */
    addGroupFields(record, viewField, language, isInitializedFunction, buildFieldFunction, addRecordFunction) {
        const definition = (viewField && viewField.fieldDefinition) || {};
        const groupFields = definition.groupFields || {};
        const groupFieldsKeys = Object.keys(groupFields);
        groupFieldsKeys.forEach(key => {
            const fieldDefinition = groupFields[key];
            if (isInitializedFunction(record, key)) {
                return;
            }
            if (fieldDefinition && fieldDefinition.type === 'relate' && fieldDefinition.type_name === 'parent_type') {
                fieldDefinition.module = record.attributes.parent_type;
            }
            const groupViewField = {
                name: fieldDefinition.name,
                label: fieldDefinition.vname,
                type: fieldDefinition.type,
                fieldDefinition
            };
            const groupField = buildFieldFunction(record, groupViewField, language);
            groupField.source = 'groupField';
            addRecordFunction(record, fieldDefinition.name, groupField);
        });
    }
    static { this.ɵfac = function GroupFieldBuilder_Factory(t) { return new (t || GroupFieldBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GroupFieldBuilder, factory: GroupFieldBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupFieldBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AttributeBuilder extends FieldBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        super(validationManager, typeFormatter, fieldRegistry);
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Create and add attributes fields to field
     *
     * @param {object} record Record
     * @param {object} fields FieldMap
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @param {function} buildAttributeFunction
     * @param {function} addAttributeFunction
     */
    addAttributes(record, fields, viewField, language, buildAttributeFunction, addAttributeFunction) {
        const fieldKeys = Object.keys(fields) || [];
        if (fieldKeys.length < 1) {
            return;
        }
        fieldKeys.forEach(key => {
            const field = fields[key];
            this.addFieldAttributes(record, field, language, buildAttributeFunction, addAttributeFunction);
        });
    }
    /**
     * Create and add attributes fields to field
     *
     * @param {object} record Record
     * @param {object} field Field
     * @param {object} language LanguageStore
     * @param {function} buildAttributeFunction
     * @param {function} addAttributeFunction
     */
    addFieldAttributes(record, field, language, buildAttributeFunction, addAttributeFunction) {
        const definition = (field && field.definition) || {};
        const attributes = definition.attributeFields || {};
        const attributeKeys = Object.keys(attributes);
        attributeKeys.forEach(key => {
            const attributeDefinition = attributes[key];
            if (!!field.attributes[key]) {
                return;
            }
            const attributeViewField = {
                name: attributeDefinition.name,
                label: attributeDefinition.vname,
                type: attributeDefinition.type,
                fieldDefinition: attributeDefinition
            };
            const attributeField = buildAttributeFunction(record, field, attributeViewField, language);
            addAttributeFunction(record, field, attributeDefinition.name, attributeField);
        });
    }
    /**
     * Build field
     *
     * @param {object} record Record
     * @param {object} parentField Field
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object} FieldAttribute
     */
    buildAttribute(record, parentField, viewField, language = null) {
        const definition = (viewField && viewField.fieldDefinition) || {};
        const { value, valueList, valueObject } = this.parseAttributeValue(viewField, definition, record, parentField);
        const { validators, asyncValidators } = this.getSaveValidators(record, viewField);
        const field = this.setupField(record.module, viewField, value, valueList, valueObject, record, definition, validators, asyncValidators, language);
        const fieldAttribute = field;
        fieldAttribute.valuePath = definition.valuePath;
        fieldAttribute.valueParent = definition.valueParent;
        fieldAttribute.source = 'attribute';
        fieldAttribute.parentKey = parentField.name;
        return fieldAttribute;
    }
    /**
     * Add attribute to record
     *
     * @param {object} record Record
     * @param {object} field Field
     * @param {string} name string
     * @param {object} attribute FieldAttribute
     */
    addAttributeToRecord(record, field, name, attribute) {
        if (!record || !name || !field || !attribute) {
            return;
        }
        field.attributes = field.attributes || {};
        field.attributes[name] = attribute;
        if (record.formGroup && attribute.formControl) {
            record.formGroup.addControl(name, attribute.formControl);
        }
    }
    /**
     * Parse attribute from field
     *
     * @param {object} viewField ViewFieldDefinition
     * @param {object} definition FieldDefinition
     * @param {object} record Record
     * @param {object} field Field
     * @returns {object} value object
     */
    parseAttributeValue(viewField, definition, record, field) {
        const type = (viewField && viewField.type) || '';
        const source = (definition && definition.source) || '';
        const rname = (definition && definition.rname) || 'name';
        const viewName = viewField.name || '';
        let value;
        let valueList = null;
        if (type === 'relate' && source === 'non-db' && rname !== '') {
            value = this.getParentValue(record, field, viewName, definition)[rname];
            const valueObject = this.getParentValue(record, field, viewName, definition);
            return { value, valueList, valueObject };
        }
        if (!viewName) {
            value = '';
        }
        else {
            value = this.getParentValue(record, field, viewName, definition);
        }
        value = this.getParentValue(record, field, viewName, definition);
        if (Array.isArray(value)) {
            return {
                value: null,
                valueList: value,
                valueObject: null
            };
        }
        if (isObjectLike(value)) {
            return {
                value: null,
                valueList: null,
                valueObject: value
            };
        }
        return { value, valueList: null, valueObject: null };
    }
    static { this.ɵfac = function AttributeBuilder_Factory(t) { return new (t || AttributeBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AttributeBuilder, factory: AttributeBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AttributeBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FilterFieldBuilder extends FieldBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        super(validationManager, typeFormatter, fieldRegistry);
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Build filter field
     *
     * @param {object} savedFilter SavedFilter
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object} Field
     */
    buildFilterField(savedFilter, viewField, language = null) {
        const definition = (viewField && viewField.fieldDefinition) || {};
        const { validators, asyncValidators } = this.getFilterValidators(savedFilter, viewField);
        const field = this.setupField(savedFilter.searchModule, viewField, null, null, null, savedFilter, definition, validators, asyncValidators, language);
        field.criteria = this.initFieldFilter(savedFilter.criteria, viewField, field);
        return field;
    }
    /**
     * Get Filter Validators for given field definition
     *
     * @param {object} record  Record
     * @param {object} viewField ViewFieldDefinition
     * @returns {object} validator map
     */
    getFilterValidators(record, viewField) {
        const validators = this.validationManager.getFilterValidations(record.searchModule, viewField, record);
        const asyncValidators = [];
        return { validators, asyncValidators };
    }
    /**
     * Init filter fields
     *
     * @param {object} searchCriteria to use
     * @param {object} viewField to init
     * @param {object} field to init
     * @returns {object} SearchCriteriaFieldFilter
     */
    initFieldFilter(searchCriteria, viewField, field) {
        let fieldCriteria;
        const fieldName = viewField.name;
        let fieldType = viewField.type;
        let rangeSearch = false;
        if (fieldType === 'composite') {
            fieldType = field.definition.type;
            rangeSearch = true;
        }
        if (searchCriteria.filters[fieldName] && searchCriteria.filters[fieldName].fieldType) {
            fieldCriteria = deepClone(searchCriteria.filters[fieldName]);
        }
        else {
            fieldCriteria = {
                field: fieldName,
                fieldType,
                operator: '',
                values: []
            };
        }
        fieldCriteria.rangeSearch = rangeSearch;
        this.mapEnumEmptyOption(fieldCriteria, field);
        this.mapRelateFields(fieldCriteria, field, searchCriteria);
        return fieldCriteria;
    }
    mapEnumEmptyOption(fieldCriteria, field) {
        if (!['multienum', 'enum'].includes(fieldCriteria.fieldType)) {
            return;
        }
        let emptyOption = this.getEmptyOption(field);
        if (!emptyOption) {
            return;
        }
        if (!fieldCriteria.values || !fieldCriteria.values.length) {
            return;
        }
        fieldCriteria.values = fieldCriteria.values.map(value => {
            if (value !== '') {
                return value;
            }
            return '__SuiteCRMEmptyString__';
        });
    }
    mapRelateFields(fieldCriteria, field, searchCriteria) {
        if (!['relate'].includes(fieldCriteria.fieldType)) {
            return;
        }
        if (!fieldCriteria.values || !fieldCriteria.values.length) {
            return;
        }
        const idFieldName = (field && field.definition && field.definition.id_name) || '';
        const relateFieldName = (field && field.definition && field.definition.rname) || 'name';
        const idValues = searchCriteria?.filters[idFieldName]?.values ?? [];
        fieldCriteria.valueObjectArray = fieldCriteria.valueObjectArray ?? [];
        const relateFieldMap = {};
        if (fieldCriteria.valueObjectArray.length) {
            fieldCriteria.valueObjectArray.forEach(value => {
                relateFieldMap[value.id] = value;
            });
        }
        for (let i = 0; i < fieldCriteria.values.length; i++) {
            let value = fieldCriteria.values[i];
            const relateValue = {};
            relateValue[relateFieldName] = value;
            relateValue['id'] = idValues[i] ?? '';
            if (!relateFieldMap[relateValue['id']]) {
                relateFieldMap[relateValue['id']] = relateValue;
                fieldCriteria.valueObjectArray.push(relateValue);
            }
        }
    }
    getEmptyOption(field) {
        let emptyOption = null;
        const extraOptions = field?.definition?.metadata?.extraOptions ?? [];
        extraOptions.forEach(option => {
            if (option.value === '__SuiteCRMEmptyString__') {
                emptyOption = option;
            }
        });
        return emptyOption;
    }
    /**
     * Is criteria field initialized in record
     *
     * @param {object} record Record
     * @param {string} fieldName field
     * @returns {boolean} isInitialized
     */
    isCriteriaFieldInitialized(record, fieldName) {
        const criteriaField = record.criteriaFields[fieldName];
        return !!criteriaField && !criteriaField.vardefBased;
    }
    /**
     * Add field to SavedFilter
     *
     * @param {object} savedFilter SavedFilter
     * @param {string} name string
     * @param {object} field Field
     */
    addToSavedFilter(savedFilter, name, field) {
        if (!savedFilter || !name || !field) {
            return;
        }
        if (!savedFilter.criteriaFields) {
            savedFilter.criteriaFields = {};
        }
        savedFilter.criteriaFields[name] = field;
        if (!savedFilter.criteria.filters) {
            savedFilter.criteria.filters = {};
        }
        savedFilter.criteria.filters[name] = field.criteria;
        if (savedFilter.criteriaFormGroup && field.formControl) {
            savedFilter.criteriaFormGroup.addControl(name, field.formControl);
        }
    }
    static { this.ɵfac = function FilterFieldBuilder_Factory(t) { return new (t || FilterFieldBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterFieldBuilder, factory: FilterFieldBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterFieldBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FilterAttributeBuilder extends FilterFieldBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        super(validationManager, typeFormatter, fieldRegistry);
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Build filter attribute
     *
     * @param {object} savedFilter SavedFilter
     * @param {object} parentField Field
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object} FieldAttribute
     */
    buildFilterAttribute(savedFilter, parentField, viewField, language = null) {
        const definition = (viewField && viewField.fieldDefinition) || {};
        if (!definition.valuePath) {
            definition.valuePath = 'criteria.' + (viewField.name || definition.name);
        }
        const { value, valueList, valueObject } = this.parseFilterAttributeValue(viewField, definition, savedFilter, parentField);
        const { validators, asyncValidators } = this.getFilterValidators(savedFilter, viewField);
        const field = this.setupField(savedFilter.searchModule, viewField, value, valueList, valueObject, savedFilter, definition, validators, asyncValidators, language);
        const fieldAttribute = field;
        fieldAttribute.valuePath = definition.valuePath;
        fieldAttribute.source = 'attribute';
        fieldAttribute.parentKey = parentField.definition.name;
        return fieldAttribute;
    }
    /**
     * Add attribute to SavedFilter
     *
     * @param {object} savedFilter SavedFilter
     * @param {object} field Field
     * @param {string} name string
     * @param {object} attribute FieldAttribute
     */
    addAttributeToSavedFilter(savedFilter, field, name, attribute) {
        if (!savedFilter || !name || !field || !attribute) {
            return;
        }
        field.attributes = field.attributes || {};
        field.attributes[name] = attribute;
        if (savedFilter.criteriaFormGroup && attribute.formControl) {
            savedFilter.criteriaFormGroup.addControl(name, attribute.formControl);
        }
    }
    /**
     * Parse filter attribute from field
     *
     * @param {object} viewField ViewFieldDefinition
     * @param {object} definition FieldDefinition
     * @param {object} record Record
     * @param {object} field Field
     * @returns {object} value object
     */
    parseFilterAttributeValue(viewField, definition, record, field) {
        const viewName = viewField.name || '';
        let value;
        if (!viewName) {
            value = '';
        }
        else {
            value = this.getParentValue(record, field, viewName, definition);
        }
        if (Array.isArray(value)) {
            return {
                value: null,
                valueList: value,
                valueObject: null
            };
        }
        if (isObjectLike(value)) {
            return {
                value: null,
                valueList: null,
                valueObject: value
            };
        }
        return { value, valueList: null, valueObject: null };
    }
    static { this.ɵfac = function FilterAttributeBuilder_Factory(t) { return new (t || FilterAttributeBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterAttributeBuilder, factory: FilterAttributeBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterAttributeBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineItemBuilder extends AttributeBuilder {
    constructor(validationManager, typeFormatter, fieldRegistry) {
        super(validationManager, typeFormatter, fieldRegistry);
        this.validationManager = validationManager;
        this.typeFormatter = typeFormatter;
        this.fieldRegistry = fieldRegistry;
    }
    /**
     * Create and add attributes fields to field
     *
     * @param {object} record Record
     * @param {object} fields FieldMap
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @param {function} buildLineItemFunction
     */
    addLineItems(record, fields, viewField, language, buildLineItemFunction) {
        const fieldKeys = Object.keys(fields) || [];
        if (fieldKeys.length < 1) {
            return;
        }
        fieldKeys.forEach(key => {
            const field = fields[key];
            this.addFieldLineItems(record, field, language, buildLineItemFunction);
        });
    }
    /**
     * Create and add attributes fields to field
     *
     * @param {object} record Record
     * @param {object} field Field
     * @param {object} language LanguageStore
     * @param {function} buildLineItemFunction
     */
    addFieldLineItems(record, field, language, buildLineItemFunction) {
        const definition = (field && field.definition) || {};
        const type = (field && field.type) || '';
        const items = (field.valueObjectArray && field.valueObjectArray) || [];
        if (type !== 'line-items' || !items.length) {
            return;
        }
        const itemDefinition = definition.lineItems?.definition || {};
        field.items = [];
        items.forEach(item => {
            this.addLineItem(itemDefinition, item, buildLineItemFunction, language, record, field);
        });
    }
    /**
     * Build line item and and to record
     * @param {object} itemDefinition
     * @param {object }item
     * @param {object} buildLineItemFunction
     * @param {object} language
     * @param {object} parentRecord
     * @param {object} parentField
     */
    addLineItem(itemDefinition, item, buildLineItemFunction, language, parentRecord, parentField) {
        const itemViewField = {
            name: itemDefinition.name,
            label: itemDefinition.vname,
            type: itemDefinition.type,
            fieldDefinition: deepClone(itemDefinition)
        };
        const itemRecord = {
            id: item.id || '',
            type: item.type || '',
            module: item.module || '',
            attributes: item.attributes || {},
            fields: {},
            formGroup: new UntypedFormGroup({})
        };
        buildLineItemFunction(itemRecord, itemViewField, language);
        parentField.itemFormArray.push(itemRecord.formGroup);
        parentField.items.push(itemRecord);
    }
    static { this.ɵfac = function LineItemBuilder_Factory(t) { return new (t || LineItemBuilder)(i0.ɵɵinject(ValidationManager), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(FieldObjectRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LineItemBuilder, factory: LineItemBuilder.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineItemBuilder, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ValidationManager }, { type: DataTypeFormatter }, { type: FieldObjectRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldManager {
    constructor(fieldBuilder, groupFieldBuilder, attributeBuilder, filterFieldBuilder, filterAttributeBuilder, lineItemBuilder, languageStore) {
        this.fieldBuilder = fieldBuilder;
        this.groupFieldBuilder = groupFieldBuilder;
        this.attributeBuilder = attributeBuilder;
        this.filterFieldBuilder = filterFieldBuilder;
        this.filterAttributeBuilder = filterAttributeBuilder;
        this.lineItemBuilder = lineItemBuilder;
        this.languageStore = languageStore;
    }
    /**
     * Build minimally initialised field object
     *
     * @param {string} type field type
     * @param {string} value field value
     * @returns {object} Field
     */
    buildShallowField(type, value) {
        return {
            type,
            value,
            definition: {
                type
            }
        };
    }
    /**
     * Build and add field to record
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object}Field
     */
    addField(record, viewField, language = null) {
        const field = this.fieldBuilder.buildField(record, viewField, language);
        this.addToRecord(record, viewField.name, field);
        this.groupFieldBuilder.addGroupFields(record, viewField, language, this.isFieldInitialized.bind(this), this.fieldBuilder.buildField.bind(this.fieldBuilder), this.addToRecord.bind(this));
        this.attributeBuilder.addAttributes(record, record.fields, viewField, language, this.attributeBuilder.buildAttribute.bind(this.attributeBuilder), this.attributeBuilder.addAttributeToRecord.bind(this.attributeBuilder));
        this.lineItemBuilder.addLineItems(record, record.fields, viewField, language, this.addField.bind(this));
        return field;
    }
    /**
     * Build and add filter field to record
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object}Field
     */
    addFilterField(record, viewField, language = null) {
        if (viewField.vardefBased && !isEmpty(record.criteriaFields[viewField.name])) {
            return record.criteriaFields[viewField.name];
        }
        const field = this.filterFieldBuilder.buildFilterField(record, viewField, language);
        this.filterFieldBuilder.addToSavedFilter(record, viewField.name, field);
        this.groupFieldBuilder.addGroupFields(record, viewField, language, this.filterFieldBuilder.isCriteriaFieldInitialized.bind(this.filterFieldBuilder), this.filterFieldBuilder.buildFilterField.bind(this.filterFieldBuilder), this.filterFieldBuilder.addToSavedFilter.bind(this.filterFieldBuilder));
        this.attributeBuilder.addAttributes(record, record.criteriaFields, viewField, language, this.filterAttributeBuilder.buildFilterAttribute.bind(this.filterAttributeBuilder), this.filterAttributeBuilder.addAttributeToSavedFilter.bind(this.filterAttributeBuilder));
        return field;
    }
    /**
     * Build line item and add to record
     *
     * @param {FieldDefinition} itemDefinition Item Definition
     * @param {Record} parentRecord Parent Record
     * @param {Field} parentField Parent Field
     * @param {Record | null} item Item
     */
    addLineItem(itemDefinition, parentRecord, parentField, item = null) {
        if (!item) {
            item = {
                id: '',
                module: parentField.definition.module || '',
                attributes: {},
                fields: {},
                formGroup: new UntypedFormGroup({}),
            };
        }
        this.lineItemBuilder.addLineItem(itemDefinition, item, this.addField.bind(this), this.languageStore, parentRecord, parentField);
        parentField.itemFormArray.updateValueAndValidity();
    }
    /**
     * Remove line item
     *
     * @param {Field} parentField Parent Field
     * @param {number} index Index
     */
    removeLineItem(parentField, index) {
        const item = parentField.items[index];
        if (!item) {
            return;
        }
        item.attributes.deleted = 1;
        parentField.itemFormArray.clear();
        parentField.items.forEach(parentItem => {
            const deleted = parentItem && parentItem.attributes && parentItem.attributes.deleted;
            if (!parentItem || deleted) {
                return;
            }
            parentField.itemFormArray.push(parentItem.formGroup);
        });
        parentField.itemFormArray.updateValueAndValidity();
    }
    /**
     * Add field to record
     *
     * @param {object} record Record
     * @param {string} name string
     * @param {object} field Field
     */
    addToRecord(record, name, field) {
        if (!record || !name || !field) {
            return;
        }
        if (!record.fields) {
            record.fields = {};
        }
        record.fields[name] = field;
        if (record.formGroup && field.itemFormArray) {
            record.formGroup.addControl(name + '-items', field.itemFormArray);
        }
        if (record.formGroup && field.formControl) {
            record.formGroup.addControl(name, field.formControl);
        }
    }
    /**
     * Build and add vardef only field to record
     *
     * @param {object} record Record
     * @param {object} viewField ViewFieldDefinition
     * @param {object} language LanguageStore
     * @returns {object}Field
     */
    addVardefOnlyField(record, viewField, language = null) {
        const field = this.fieldBuilder.buildField(record, viewField, language);
        this.addVardefOnlyFieldToRecord(record, viewField.name, field);
        return field;
    }
    /**
     * Add field to record
     *
     * @param {object} record Record
     * @param {string} name string
     * @param {object} field Field
     */
    addVardefOnlyFieldToRecord(record, name, field) {
        if (!record || !name || !field) {
            return;
        }
        if (!record.fields) {
            record.fields = {};
        }
        record.fields[name] = field;
    }
    /**
     * Is field initialized in record
     *
     * @param {object} record Record
     * @param {string} fieldName field
     * @returns {boolean} isInitialized
     */
    isFieldInitialized(record, fieldName) {
        return !!record.fields[fieldName];
    }
    static { this.ɵfac = function FieldManager_Factory(t) { return new (t || FieldManager)(i0.ɵɵinject(FieldBuilder), i0.ɵɵinject(GroupFieldBuilder), i0.ɵɵinject(AttributeBuilder), i0.ɵɵinject(FilterFieldBuilder), i0.ɵɵinject(FilterAttributeBuilder), i0.ɵɵinject(LineItemBuilder), i0.ɵɵinject(LanguageStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldManager, factory: FieldManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FieldBuilder }, { type: GroupFieldBuilder }, { type: AttributeBuilder }, { type: FilterFieldBuilder }, { type: FilterAttributeBuilder }, { type: LineItemBuilder }, { type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordManager {
    constructor(fieldManager, language, fieldHandlerRegistry) {
        this.fieldManager = fieldManager;
        this.language = language;
        this.fieldHandlerRegistry = fieldHandlerRegistry;
    }
    /**
     * Get empty record
     *
     * @param {string} module string
     * @returns {object} Record
     */
    buildEmptyRecord(module) {
        return {
            id: '',
            module,
            attributes: {
                id: ''
            },
            fields: {},
            formGroup: new UntypedFormGroup({}),
        };
    }
    /**
     * Init Fields
     *
     * @param {object} record to use
     * @param {object} viewFieldDefinitions to use
     * @returns {object} fields
     */
    initFields(record, viewFieldDefinitions) {
        if (!record.fields) {
            record.fields = {};
        }
        if (!record.formGroup) {
            record.formGroup = new UntypedFormGroup({});
        }
        viewFieldDefinitions.forEach(viewField => {
            if (!viewField || !viewField.name) {
                return;
            }
            if (record.fields[viewField.name]) {
                return;
            }
            const isVardefBased = viewField?.vardefBased ?? false;
            if (isVardefBased) {
                this.fieldManager.addVardefOnlyField(record, viewField, this.language);
                return;
            }
            this.fieldManager.addField(record, viewField, this.language);
        });
        return record.fields;
    }
    initFieldDefaults(record) {
        if (!record.fields) {
            return;
        }
        Object.entries(record.fields).forEach(([key, field]) => {
            const fieldHandler = this.fieldHandlerRegistry.get(record.module, field.type);
            fieldHandler.initDefaultValue(field, record);
        });
    }
    /**
     * Inject param fields
     *
     * @param {object} params Params
     * @param {object} record Record
     * @param {object} vardefs FieldDefinitionMap
     */
    injectParamFields(params, record, vardefs) {
        Object.keys(params).forEach(paramKey => {
            const definition = vardefs[paramKey];
            if (!isVoid(definition)) {
                const type = definition.type || '';
                let idName = definition.id_name || '';
                const name = definition.name || '';
                let rname = definition.rname || '';
                if (type === 'relate' && idName === name) {
                    record.attributes[paramKey] = params[paramKey];
                    return;
                }
                if (type === 'parent') {
                    const relate = {};
                    let rname = 'name';
                    let idName = 'parent_id';
                    const groupFieldKey = paramKey + '-group';
                    const groupField = vardefs[groupFieldKey] ?? {};
                    const parentName = groupField.groupFields[paramKey];
                    if (parentName && parentName.rname) {
                        rname = parentName.rname;
                    }
                    if (rname) {
                        relate[rname] = params[paramKey];
                    }
                    if (idName && params[idName]) {
                        relate.id = params[idName];
                    }
                    record.attributes[paramKey] = relate;
                    return;
                }
                if (type === 'relate') {
                    const relate = {};
                    if (rname) {
                        relate[rname] = params[paramKey];
                    }
                    if (idName && params[idName]) {
                        relate.id = params[idName];
                    }
                    record.attributes[paramKey] = relate;
                    return;
                }
                record.attributes[paramKey] = params[paramKey];
                return;
            }
            this.handleLinkTypeRelationship(paramKey, params, vardefs, record);
        });
    }
    handleLinkTypeRelationship(paramKey, params, vardefs, record) {
        if (paramKey === 'return_relationship') {
            const returnRelationship = params.return_relationship;
            if (!returnRelationship) {
                return;
            }
            // check, on vardefs, if there is a field of type = link
            // with relationship equal to the value of return_relationship param
            Object.keys(vardefs).forEach(key => {
                const vardef = vardefs[key];
                const type = vardef.type || '';
                if (type !== 'link') {
                    return;
                }
                const relationship = vardef.relationship || '';
                if (!relationship) {
                    return;
                }
                if (relationship === returnRelationship) {
                    const linkFieldName = vardef.name;
                    const module = vardef.module ?? params.return_module ?? '';
                    if (!module) {
                        return;
                    }
                    const parentName = params.parent_name;
                    if (!parentName) {
                        return;
                    }
                    // name of the related parent field e.g. contact_id as injected
                    // in to field definition from its metadata definition
                    const relateId = vardef?.relationshipMetadata?.related_id;
                    const parentId = params[relateId] ?? '';
                    if (!parentId) {
                        return;
                    }
                    // add link type fields as line items to base record
                    record.attributes[linkFieldName] = [
                        {
                            id: parentId,
                            module,
                            attributes: {
                                id: parentId,
                                name: parentName
                            }
                        }
                    ];
                    return;
                }
            });
        }
    }
    static { this.ɵfac = function RecordManager_Factory(t) { return new (t || RecordManager)(i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(FieldHandlerRegistry)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordManager, factory: RecordManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: FieldManager }, { type: LanguageStore }, { type: FieldHandlerRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseComposite extends BaseFieldComponent {
    constructor(typeFormatter, registry, recordManager, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.registry = registry;
        this.recordManager = recordManager;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.initUpdateParentSubscription();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getComponentType(type, definition) {
        let module = (this.record && this.record.module) || 'default';
        const displayType = (definition && definition.displayType) || '';
        return this.registry.getDisplayType(module, type, displayType, this.getMode(), this.field.name);
    }
    /**
     * Get the attribute fields from the field
     *
     * @returns {object} Field[]
     */
    getAttributes() {
        const fields = [];
        this.field.definition.layout.forEach(name => {
            if (!this.field.attributes[name] || this.field.attributes[name].display === 'none') {
                return;
            }
            fields.push(this.field.attributes[name]);
        });
        return fields;
    }
    getModule() {
        if (!this.record) {
            return null;
        }
        return this.record.module;
    }
    getMode() {
        if (this.mode === 'filter') {
            return 'edit';
        }
        return this.mode;
    }
    /**
     * Get flex direction to be used
     *
     * @returns {string} direction
     */
    getDirection() {
        let direction = 'flex-column';
        if (this.field.definition.display === 'inline') {
            direction = 'flex-row';
        }
        return direction;
    }
    /**
     * Check if is configured
     *
     * @returns {boolean} is configured
     */
    isConfigured() {
        return this.hasDisplay() && this.hasLayout() && this.hasAttributes();
    }
    /**
     * Show label
     * @param attribute
     */
    showLabel(attribute) {
        const definition = attribute.definition || null;
        const showLabel = definition.showLabel || null;
        const labelDisplay = (attribute.metadata && attribute.metadata.labelDisplay) || '';
        if (!definition || !showLabel || labelDisplay === 'hide') {
            return false;
        }
        return (showLabel.includes('*') || showLabel.includes(this.mode));
    }
    /**
     * Check if groupFields are configured
     *
     * @returns {boolean} has groupFields
     */
    hasAttributes() {
        return !!(this.field.definition.attributeFields && !emptyObject(this.field.definition.attributeFields));
    }
    /**
     * Check if layout is configured
     *
     * @returns {boolean} has layout
     */
    hasLayout() {
        return !!(this.field.definition.layout && this.field.definition.layout.length);
    }
    /**
     * Check if display is configured
     *
     * @returns {boolean} has display
     */
    hasDisplay() {
        return !!this.field.definition.display;
    }
    /**
     * Init Update parent subscription
     */
    initUpdateParentSubscription() {
        if (!this.field.attributes) {
            return;
        }
        Object.keys(this.field.attributes).forEach(attributeKey => {
            const attribute = this.field.attributes[attributeKey];
            if (!attribute.valueChanges$) {
                return;
            }
            this.subs.push(attribute.valueChanges$.subscribe(value => {
                const val = value.valueObject || value.valueList || value.value;
                this.setValueOnParent(attribute, val);
            }));
        });
    }
    /**
     * Set attribute value on parent
     *
     * @param {object} attribute
     * @param {} value
     */
    setValueOnParent(attribute, value) {
        const valueParent = attribute.valueParent ?? 'field';
        const parent = valueParent === 'record' ? this.record : this.field;
        if (attribute.valuePath) {
            set(parent, attribute.valuePath, value);
            return;
        }
        if (valueParent === 'record') {
            set(this.record.attributes, attribute.name, value);
        }
        else {
            set(this.field.valueObject, attribute.name, value);
        }
    }
    static { this.ɵfac = function BaseComposite_Factory(t) { return new (t || BaseComposite)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(StandardFieldRegistry), i0.ɵɵdirectiveInject(RecordManager), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseComposite, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseComposite_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseComposite, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DataTypeFormatter }, { type: StandardFieldRegistry }, { type: RecordManager }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function CompositeComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 1);
    i0.ɵɵelementContainerEnd();
} }
function CompositeComponent_ng_container_1_div_2_label_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "span", 7);
    i0.ɵɵtext(2, "*");
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
const _c0$z = function () { return ["edit", "create"]; };
function CompositeComponent_ng_container_1_div_2_label_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "label");
    i0.ɵɵelement(1, "scrm-label", 6);
    i0.ɵɵtemplate(2, CompositeComponent_ng_container_1_div_2_label_2_ng_container_2_Template, 3, 0, "ng-container", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const attribute_r3 = i0.ɵɵnextContext().$implicit;
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", attribute_r3.labelKey)("module", ctx_r4.getModule());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", attribute_r3.definition.required && i0.ɵɵpureFunction0(3, _c0$z).includes(ctx_r4.mode));
} }
function CompositeComponent_ng_container_1_div_2_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "scrm-dynamic-field", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const attribute_r3 = i0.ɵɵnextContext().$implicit;
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("componentType", ctx_r5.getComponentType(attribute_r3.type, attribute_r3.definition))("field", attribute_r3)("klass", ctx_r5.klass)("mode", ctx_r5.getMode())("originalMode", ctx_r5.originalMode)("record", ctx_r5.record)("parent", ctx_r5.parent)("type", attribute_r3.type);
} }
function CompositeComponent_ng_container_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3)(1, "span", 4);
    i0.ɵɵtemplate(2, CompositeComponent_ng_container_1_div_2_label_2_Template, 3, 4, "label", 0);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, CompositeComponent_ng_container_1_div_2_span_3_Template, 2, 8, "span", 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const attribute_r3 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("flex-fill", ctx_r2.mode === "edit" && ctx_r2.getDirection() === "flex-row")("align-self-start", ctx_r2.getDirection() === "flex-row" && attribute_r3.labelKey && ctx_r2.showLabel(attribute_r3));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", attribute_r3.labelKey && ctx_r2.showLabel(attribute_r3));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", attribute_r3.type);
} }
function CompositeComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵtemplate(2, CompositeComponent_ng_container_1_div_2_Template, 4, 6, "div", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("d-flex ", ctx_r1.getDirection(), " justify-content-start align-items-end field-group h-100 composite-field-wrapper");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r1.getAttributes());
} }
class CompositeComponent extends BaseComposite {
    constructor(typeFormatter, registry, recordManager, logic, logicDisplay) {
        super(typeFormatter, registry, recordManager, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.registry = registry;
        this.recordManager = recordManager;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function CompositeComponent_Factory(t) { return new (t || CompositeComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(StandardFieldRegistry), i0.ɵɵdirectiveInject(RecordManager), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CompositeComponent, selectors: [["scrm-composite-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [[4, "ngIf"], ["labelKey", "LBL_BAD_GROUP_FIELD_CONFIG"], ["class", "field-group-item d-flex flex-column justify-content-end h-100 w-100", 3, "flex-fill", "align-self-start", 4, "ngFor", "ngForOf"], [1, "field-group-item", "d-flex", "flex-column", "justify-content-end", "h-100", "w-100"], [1, "field-group-label", "pt-2", "pr-1"], ["class", "field-group-field pr-1 pb-1 composite-field", 4, "ngIf"], [3, "labelKey", "module"], [1, "required"], [1, "field-group-field", "pr-1", "pb-1", "composite-field"], [3, "componentType", "field", "klass", "mode", "originalMode", "record", "parent", "type"]], template: function CompositeComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, CompositeComponent_ng_container_0_Template, 2, 0, "ng-container", 0);
            i0.ɵɵtemplate(1, CompositeComponent_ng_container_1_Template, 3, 4, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.isConfigured());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.isConfigured());
        } }, dependencies: [i2.NgForOf, i2.NgIf, LabelComponent, DynamicFieldComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CompositeComponent, [{
        type: Component,
        args: [{ selector: 'scrm-composite-field', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!isConfigured()\">\n    <scrm-label labelKey=\"LBL_BAD_GROUP_FIELD_CONFIG\"></scrm-label>\n</ng-container>\n\n<ng-container *ngIf=\"isConfigured()\">\n    <div class=\"d-flex {{getDirection()}} justify-content-start align-items-end field-group h-100 composite-field-wrapper\">\n\n        <div *ngFor=\"let attribute of getAttributes()\"\n             [class.flex-fill]=\"mode ==='edit' && getDirection() === 'flex-row'\"\n             [class.align-self-start]=\"getDirection() === 'flex-row' && attribute.labelKey && showLabel(attribute)\"\n             class=\"field-group-item d-flex flex-column justify-content-end h-100 w-100\">\n\n            <!-- LABEL -->\n            <span class=\"field-group-label pt-2 pr-1\">\n                <label *ngIf=\"attribute.labelKey && showLabel(attribute)\">\n                    <scrm-label [labelKey]=\"attribute.labelKey\" [module]=\"getModule()\"></scrm-label>\n                    <ng-container *ngIf=\"attribute.definition.required && (['edit', 'create'].includes(mode))\">\n                        <span class=\"required\">*</span>\n                    </ng-container>\n                </label>\n            </span>\n\n            <!-- VALUE -->\n            <span *ngIf=\"attribute.type\" class=\"field-group-field pr-1 pb-1 composite-field\">\n\n                <scrm-dynamic-field [componentType]=\"getComponentType(attribute.type, attribute.definition)\"\n                                    [field]=\"attribute\"\n                                    [klass]=\"klass\"\n                                    [mode]=\"getMode()\"\n                                    [originalMode]=\"originalMode\"\n                                    [record]=\"record\"\n                                    [parent]=\"parent\"\n                                    [type]=\"attribute.type\">\n                </scrm-dynamic-field>\n\n            </span>\n        </div>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: StandardFieldRegistry }, { type: RecordManager }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CompositeModule {
    static { this.ɵfac = function CompositeModule_Factory(t) { return new (t || CompositeModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CompositeModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule,
            DynamicFieldModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CompositeModule, [{
        type: NgModule,
        args: [{
                declarations: [CompositeComponent, BaseComposite],
                imports: [
                    CommonModule,
                    LabelModule,
                    DynamicFieldModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CompositeModule, { declarations: [CompositeComponent, BaseComposite], imports: [CommonModule,
        LabelModule,
        DynamicFieldModule] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const fieldModules = [
    ...baseFieldModules,
    GroupFieldModule,
    CompositeModule
];
const fieldComponents = [
    ...baseFieldComponents,
    GroupFieldComponent,
    CompositeComponent
];
const viewFieldsMap = {
    ...baseViewFieldsMap,
    'grouped-field.list': GroupFieldComponent,
    'grouped-field.detail': GroupFieldComponent,
    'grouped-field.edit': GroupFieldComponent,
    'grouped-field.filter': GroupFieldComponent,
    'composite.list': CompositeComponent,
    'composite.detail': CompositeComponent,
    'composite.edit': CompositeComponent,
    'composite.filter': CompositeComponent,
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldRegistry extends BaseFieldRegistry {
    constructor() {
        super();
    }
    getDefaultMap() {
        return viewFieldsMap;
    }
    static { this.ɵfac = function FieldRegistry_Factory(t) { return new (t || FieldRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldRegistry, factory: FieldRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

class RecordValidationHandler {
    /**
     * Initialize Record Validators
     * @param record
     */
    initValidators(record) {
        if (!record) {
            return;
        }
        record?.formGroup?.clearValidators();
        const fields = record?.fields ?? {};
        Object.keys(fields).forEach(fieldName => {
            const field = record.fields[fieldName];
            const formControl = field?.formControl ?? null;
            if (!formControl) {
                return;
            }
            this.initFieldValidators(field);
            this.initLineItemsValidators(field);
        });
    }
    /**
     * reset record field validators
     * @param record
     */
    resetValidators(record) {
        if (!record) {
            return;
        }
        record?.formGroup?.clearValidators();
        const fields = record?.fields ?? {};
        Object.keys(fields).forEach(fieldName => {
            const field = record.fields[fieldName];
            this.resetFieldValidators(field);
            this.resetLineItemsValidators(field);
        });
    }
    /**
     * Set field validators
     * @param field
     * @param validators
     * @param asyncValidators
     */
    setFormControlValidators(field, validators, asyncValidators) {
        if (!field?.formControl) {
            return;
        }
        if (validators?.length) {
            field.formControl.setValidators(validators);
        }
        if (asyncValidators?.length) {
            field.formControl.setAsyncValidators(asyncValidators);
        }
    }
    /**
     * Reset field validators
     * @param field
     */
    resetFormControlValidators(field) {
        if (!field?.formControl) {
            return;
        }
        field.formControl.clearValidators();
        field.formControl.clearAsyncValidators();
    }
    /**
     * Initialize Field validators
     * @param field
     */
    initFieldValidators(field) {
        this.resetFormControlValidators(field);
        this.setFormControlValidators(field, field?.validators ?? [], field?.asyncValidators ?? []);
        const fieldAttributes = field?.attributes ?? {};
        Object.keys(fieldAttributes).forEach(fieldAttributeName => {
            const fieldAttribute = fieldAttributes[fieldAttributeName];
            this.resetFormControlValidators(fieldAttribute);
            this.setFormControlValidators(fieldAttribute, fieldAttribute?.validators ?? [], fieldAttribute?.asyncValidators ?? []);
        });
    }
    /**
     * Initialize Field validators
     * @param field
     */
    resetFieldValidators(field) {
        this.resetFormControlValidators(field);
        const fieldAttributes = field?.attributes ?? {};
        Object.keys(fieldAttributes).forEach(fieldAttributeName => {
            const fieldAttribute = fieldAttributes[fieldAttributeName];
            this.resetFormControlValidators(fieldAttribute);
        });
    }
    /**
     * Initialize Line Items validators
     * @param field
     */
    initLineItemsValidators(field) {
        if (!field?.itemFormArray) {
            return;
        }
        const itemFormArraySaveValidators = field?.itemFormArraySaveValidators ?? [];
        if (itemFormArraySaveValidators.length) {
            field.itemFormArray.clearValidators();
            field.itemFormArray.addValidators(itemFormArraySaveValidators);
        }
        const items = field?.items ?? [];
        items.forEach(item => {
            const itemFields = item?.fields ?? {};
            Object.keys(itemFields).forEach(itemFieldName => {
                const itemField = itemFields[itemFieldName];
                this.initFieldValidators(itemField);
            });
        });
    }
    /**
     * Initialize Line Items validators
     * @param field
     */
    resetLineItemsValidators(field) {
        if (!field?.itemFormArray) {
            return;
        }
        field.itemFormArray.clearValidators();
        const items = field?.items ?? [];
        items.forEach(item => {
            const itemFields = item?.fields ?? {};
            Object.keys(itemFields).forEach(itemFieldName => {
                const itemField = itemFields[itemFieldName];
                this.resetFieldValidators(field);
            });
        });
    }
    static { this.ɵfac = function RecordValidationHandler_Factory(t) { return new (t || RecordValidationHandler)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordValidationHandler, factory: RecordValidationHandler.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordValidationHandler, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseLineItemsComponent extends BaseFieldComponent {
    constructor(typeFormatter, registry, recordManager, logic, fieldManager, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.registry = registry;
        this.recordManager = recordManager;
        this.logic = logic;
        this.fieldManager = fieldManager;
        this.logicDisplay = logicDisplay;
        this.recordValidationHandler = inject(RecordValidationHandler);
    }
    ngOnInit() {
        super.ngOnInit();
        this.initUpdateParentSubscription();
        this.initItems();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    /**
     * Get component type
     * @param {string} type
     * @param {FieldDefinition} definition
     * @returns {}
     */
    getComponentType(type, definition) {
        const module = (this.record && this.record.module) || 'default';
        const displayType = (definition && definition.displayType) || '';
        return this.registry.getDisplayType(module, type, displayType, this.getMode(), this.field.name);
    }
    /**
     * Get the list of items
     *
     * @returns {object} Record[]
     */
    initItems() {
        this.field.items = this.field.items || [];
        const items = this.field.items;
        const activeItems = items && items.filter(item => !(item && item.attributes && item.attributes.deleted));
        const labelOnFirstLine = !!(this.field?.definition?.lineItems?.labelOnFirstLine ?? false);
        activeItems.forEach((item, index) => {
            const show = !labelOnFirstLine || index <= 0;
            this.setAttributeLabelDisplay(item, show);
        });
    }
    initEmptyItem() {
        this.field.items = this.field.items || [];
        const items = this.field.items;
        const activeItems = items && items.filter(item => !(item && item.attributes && item.attributes.deleted));
        if (['edit', 'create'].includes(this.mode) && !activeItems.length) {
            this.addEmptyItem();
        }
    }
    /**
     * Get the fields for the item record
     *
     * @param {Record} item
     * @returns {object} Field[]
     */
    getItemFields(item) {
        const fields = item.fields || {};
        return Object.keys(fields).map(key => fields[key]);
    }
    /**
     * Remove item from array
     *
     * @param {number} index
     * @return {void}
     */
    removeItem(index) {
        this.fieldManager.removeLineItem(this.field, index);
        const activeItems = this.getActiveItems();
        const itemCount = activeItems?.length ?? 0;
        if (itemCount) {
            this.setAttributeLabelOnItem(0, activeItems);
        }
        this.updateItems(this.field.items);
        this.triggerLineActionEvents(LineActionEvent.onLineItemRemove);
    }
    /**
     * Add item to array
     *
     * @return {void}
     */
    addEmptyItem() {
        const itemDefinition = this.field?.definition?.lineItems?.definition || {};
        this.fieldManager.addLineItem(itemDefinition, this.record, this.field);
        const activeItems = this.getActiveItems();
        const itemCount = activeItems?.length ?? 0;
        if (itemCount) {
            this.setAttributeLabelOnItem(0, activeItems);
            this.setAttributeLabelOnItem(itemCount - 1, activeItems);
        }
        this.recordValidationHandler.initLineItemsValidators(this.field);
        this.triggerLineActionEvents(LineActionEvent.onLineItemAdd);
    }
    /**
     * Update items
     *
     * @param {Record[]} items
     * @return {void}
     */
    updateItems(items) {
        this.field.items = items;
    }
    /**
     * Get module
     *
     * @return {string}
     */
    getModule() {
        if (!this.record) {
            return null;
        }
        return this.record.module;
    }
    /**
     * Get Mode
     *
     * @return {string}
     */
    getMode() {
        if (this.mode === 'filter') {
            return 'edit';
        }
        return this.mode;
    }
    /**
     * Get flex direction to be used
     *
     * @returns {string} direction
     */
    getDirection() {
        let direction = 'flex-column';
        if (this.field.definition.display === 'inline') {
            direction = 'flex-row';
        }
        return direction;
    }
    /**
     * Check if is configured
     *
     * @returns {boolean} is configured
     */
    isConfigured() {
        return this.hasItemConfig();
    }
    /**
     * Check if its editable
     */
    isEditable() {
        return isEditable(this.mode);
    }
    /**
     * Show label
     *
     * @param {FieldAttribute} attribute
     * @returns {boolean}
     */
    showLabel(attribute) {
        const definition = attribute.definition || null;
        const showLabel = definition.showLabel || null;
        if (!definition || !showLabel) {
            return false;
        }
        return (showLabel.includes('*') || showLabel.includes(this.mode));
    }
    /**
     * Get message context
     *
     * @param {} item
     * @param {Record} record
     * @return {object} StringMap
     */
    getMessageContext(item, record) {
        const context = item && item.message && item.message.context || {};
        context.module = (record && record.module) || '';
        return context;
    }
    /**
     * Get message label key
     *
     * @param {} item
     * @return {string}
     */
    getMessageLabelKey(item) {
        return (item && item.message && item.message.labelKey) || '';
    }
    /**
     * Get active items
     */
    getActiveItems() {
        const items = this?.field?.items ?? [];
        return items.filter(item => !(item?.attributes?.deleted ?? false));
    }
    /**
     * Calculate if items' attribute label should show or hide
     * @param index on the element
     * @param items list
     */
    setAttributeLabelOnItem(index, items) {
        const labelOnFirstLine = !!(this.field?.definition?.lineItems?.labelOnFirstLine ?? false);
        const show = !labelOnFirstLine || (index <= 0);
        this.setAttributeLabelDisplay(items[index], show);
    }
    /**
     * Check if groupFields are configured
     *
     * @returns {boolean} has groupFields
     */
    hasItemConfig() {
        return !!(this.field?.definition?.lineItems?.definition ?? null);
    }
    /**
     * Init Update parent subscription
     */
    initUpdateParentSubscription() {
        if (!this.field.attributes) {
            return;
        }
        Object.keys(this.field.attributes).forEach(attributeKey => {
            const attribute = this.field.attributes[attributeKey];
            if (!attribute.valueChanges$) {
                return;
            }
            this.subs.push(attribute.valueChanges$.subscribe(value => {
                const val = value.valueObject || value.valueList || value.value;
                this.setValueOnParent(attribute, val);
            }));
        });
    }
    /**
     * Set attribute value on parent
     *
     * @param {object} attribute
     * @param {} value
     * @returns {void}
     */
    setValueOnParent(attribute, value) {
        if (attribute.valuePath) {
            set(this.field, attribute.valuePath, value);
            return;
        }
        set(this.field.valueObject, attribute.name, value);
    }
    /**
     * Set attribute label display
     *
     * @param {object} itemRecord
     * @param {boolean} showLabel
     * @returns {void}
     */
    setAttributeLabelDisplay(itemRecord, showLabel) {
        const subfields = itemRecord.fields || {};
        Object.keys(subfields).forEach(subFieldKey => {
            const subField = subfields[subFieldKey];
            if (subField.type !== 'composite') {
                return;
            }
            const subFieldAttributes = subField.attributes || {};
            Object.keys(subFieldAttributes).forEach(subFieldAttributeKey => {
                const subFieldAttribute = subFieldAttributes[subFieldAttributeKey];
                const metadata = subFieldAttribute.metadata || {};
                metadata.labelDisplay = !showLabel ? 'hide' : 'default';
                subFieldAttribute.metadata = metadata;
            });
        });
    }
    /**
     * Check and if enabled, Run custom field logic on line action events
     * e.g. on line items row add/remove and so on as required
     *
     * @param {LineActionEvent} lineActionEvent
     * @returns {void}
     */
    triggerLineActionEvents(lineActionEvent) {
        const fieldLogics = this.field?.logic || {};
        if (emptyObject(fieldLogics)) {
            return;
        }
        Object.keys(fieldLogics).forEach(logicKey => {
            const fieldLogic = fieldLogics[logicKey] || null;
            const onEvent = fieldLogic?.params?.triggerOnEvents?.[lineActionEvent];
            if (isTrue(onEvent)) {
                this.logic.runLogic(this.field, this.mode, this.record);
            }
        });
    }
    static { this.ɵfac = function BaseLineItemsComponent_Factory(t) { return new (t || BaseLineItemsComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldRegistry), i0.ɵɵdirectiveInject(RecordManager), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseLineItemsComponent, selectors: [["ng-component"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function BaseLineItemsComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseLineItemsComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldRegistry }, { type: RecordManager }, { type: FieldLogicManager }, { type: FieldManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LineItemsComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-label", 1);
    i0.ɵɵelementContainerEnd();
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "scrm-dynamic-field", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const itemField_r12 = ctx.$implicit;
    const item_r7 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r10 = i0.ɵɵnextContext(3);
    i0.ɵɵclassMapInterpolate2("", itemField_r12.type, " ", itemField_r12.name, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("componentType", ctx_r10.getComponentType(itemField_r12.type, itemField_r12.definition))("field", itemField_r12)("klass", ctx_r10.klass)("mode", ctx_r10.mode)("originalMode", ctx_r10.originalMode)("record", item_r7)("parent", ctx_r10.parent)("type", itemField_r12.type);
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_scrm_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button", 11);
} if (rf & 2) {
    const ctx_r14 = i0.ɵɵnextContext(2);
    const item_r7 = ctx_r14.$implicit;
    const i_r8 = ctx_r14.index;
    const ctx_r11 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("config", ctx_r11.getRemoveItemButton(item_r7, i_r8));
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6)(1, "div", 7);
    i0.ɵɵtemplate(2, LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_div_2_Template, 2, 12, "div", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 9);
    i0.ɵɵtemplate(4, LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_scrm_button_4_Template, 1, 1, "scrm-button", 4);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r7 = i0.ɵɵnextContext().$implicit;
    const ctx_r9 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r9.getItemFields(item_r7));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r9.isEditable());
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_div_1_Template, 5, 2, "div", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r7 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !(item_r7 && item_r7.attributes && item_r7.attributes.deleted));
} }
function LineItemsComponent_ng_container_1_ng_container_1_scrm_button_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button", 11);
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("config", ctx_r5.getAddItemButton());
} }
const _c0$y = function (a0) { return { field: a0 }; };
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵelement(1, "scrm-dynamic-label", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r18 = ctx.$implicit;
    const ctx_r17 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("context", ctx_r17.getMessageContext(item_r18.value, ctx_r17.record))("fields", i0.ɵɵpureFunction1(3, _c0$y, ctx_r17.field))("labelKey", ctx_r17.getMessageLabelKey(item_r18.value));
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_ng_container_1_div_1_Template, 2, 5, "div", 12);
    i0.ɵɵpipe(2, "keyvalue");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r16 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(2, 1, ctx_r16.field.itemFormArray.errors));
} }
function LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_ng_container_1_Template, 3, 3, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r6.field.itemFormArray.invalid);
} }
function LineItemsComponent_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div")(2, "div");
    i0.ɵɵtemplate(3, LineItemsComponent_ng_container_1_ng_container_1_ng_container_3_Template, 2, 1, "ng-container", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 3);
    i0.ɵɵtemplate(5, LineItemsComponent_ng_container_1_ng_container_1_scrm_button_5_Template, 1, 1, "scrm-button", 4);
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(6, LineItemsComponent_ng_container_1_ng_container_1_ng_container_6_Template, 2, 1, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate2("line-items d-flex flex-column ", ctx_r2.field.type, " ", ctx_r2.field.name, "");
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("d-flex ", ctx_r2.getDirection(), " justify-content-start align-items-end line-item h-100");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2.field.items);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2.isEditable());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (ctx_r2.mode === "edit" || ctx_r2.mode === "filter") && ctx_r2.field.itemFormArray && ctx_r2.field.itemFormArray.errors);
} }
function LineItemsComponent_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 15);
    i0.ɵɵelement(2, "div", 16);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function LineItemsComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, LineItemsComponent_ng_container_1_ng_container_1_Template, 7, 10, "ng-container", 0);
    i0.ɵɵtemplate(2, LineItemsComponent_ng_container_1_ng_container_2_Template, 3, 0, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r1.field.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.field.loading);
} }
class LineItemsComponent extends BaseLineItemsComponent {
    constructor(typeFormatter, registry, recordManager, logic, fieldManager, logicDisplay) {
        super(typeFormatter, registry, recordManager, logic, fieldManager, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.registry = registry;
        this.recordManager = recordManager;
        this.logic = logic;
        this.fieldManager = fieldManager;
        this.logicDisplay = logicDisplay;
    }
    ngOnInit() {
        super.ngOnInit();
        this.field.metadata = this?.field?.metadata ?? {};
        const emptyItemInitialized = this?.field?.metadata?.emptyItemInitialized ?? false;
        if (['create'].includes(this.originalMode) && !emptyItemInitialized) {
            this.initEmptyItem();
            this.field.metadata.emptyItemInitialized = true;
        }
    }
    /**
     * Add item button config
     * @returns {object} ButtonInterface
     */
    getAddItemButton() {
        return {
            klass: 'btn btn-sm btn-outline-secondary m-0 border-0',
            icon: 'plus',
            onClick: () => {
                this.addEmptyItem();
            },
        };
    }
    /**
     * Remove item button config
     * @param {object} item
     * @param {number} index
     * @returns {object} ButtonInterface
     */
    getRemoveItemButton(item, index) {
        return {
            klass: 'btn btn-sm btn-outline-secondary m-0 border-0',
            icon: 'minimise',
            onClick: () => {
                this.removeItem(index);
            },
        };
    }
    static { this.ɵfac = function LineItemsComponent_Factory(t) { return new (t || LineItemsComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldRegistry), i0.ɵɵdirectiveInject(RecordManager), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LineItemsComponent, selectors: [["scrm-line-items-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [[4, "ngIf"], ["labelKey", "LBL_LINE_ITEMS_FIELD_CONFIG"], [4, "ngFor", "ngForOf"], [1, "line-item-buttons", "d-flex", "justify-content-end", "mt-1"], [3, "config", 4, "ngIf"], ["class", "d-flex flex-row line-item-entry w-100 align-items-end", 4, "ngIf"], [1, "d-flex", "flex-row", "line-item-entry", "w-100", "align-items-end"], [1, "flex-grow-1", "line-item-entry-composite"], [3, "class", 4, "ngFor", "ngForOf"], [1, "line-item-entry-buttons", "mb-1"], [3, "componentType", "field", "klass", "mode", "originalMode", "record", "parent", "type"], [3, "config"], ["class", "invalid-feedback d-block", 4, "ngFor", "ngForOf"], [1, "invalid-feedback", "d-block"], [3, "context", "fields", "labelKey"], [1, "dynamic-field"], [1, "flex-grow-1", "text-break", "rounded", "box-loading", "skeleton-field-content"]], template: function LineItemsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LineItemsComponent_ng_container_0_Template, 2, 0, "ng-container", 0);
            i0.ɵɵtemplate(1, LineItemsComponent_ng_container_1_Template, 3, 2, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.isConfigured());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.isConfigured());
        } }, dependencies: [i2.NgForOf, i2.NgIf, LabelComponent, DynamicFieldComponent, ButtonComponent, DynamicLabelComponent, i2.KeyValuePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineItemsComponent, [{
        type: Component,
        args: [{ selector: 'scrm-line-items-field', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!isConfigured()\">\n    <scrm-label labelKey=\"LBL_LINE_ITEMS_FIELD_CONFIG\"></scrm-label>\n</ng-container>\n\n<ng-container *ngIf=\"isConfigured()\">\n\n    <ng-container *ngIf=\"!field.loading\">\n        <div class=\"line-items d-flex flex-column {{field.type}} {{field.name}}\">\n\n            <div class=\"d-flex {{getDirection()}} justify-content-start align-items-end line-item h-100\">\n                <ng-container *ngFor=\"let item of field.items; index as i\">\n                    <div *ngIf=\"!(item && item.attributes && item.attributes.deleted)\"\n                         class=\"d-flex flex-row line-item-entry w-100 align-items-end\">\n\n                        <div class=\"flex-grow-1 line-item-entry-composite\">\n                            <div *ngFor=\"let itemField of getItemFields(item)\"\n                                 class=\"{{itemField.type}} {{itemField.name}}\">\n                                <scrm-dynamic-field [componentType]=\"getComponentType(itemField.type, itemField.definition)\"\n                                                    [field]=\"itemField\"\n                                                    [klass]=\"klass\"\n                                                    [mode]=\"mode\"\n                                                    [originalMode]=\"originalMode\"\n                                                    [record]=\"item\"\n                                                    [parent]=\"parent\"\n                                                    [type]=\"itemField.type\">\n                                </scrm-dynamic-field>\n                            </div>\n                        </div>\n\n                        <div class=\"line-item-entry-buttons mb-1\">\n                            <scrm-button *ngIf=\"isEditable()\" [config]=\"getRemoveItemButton(item, i)\">\n                            </scrm-button>\n                        </div>\n                    </div>\n                </ng-container>\n\n\n            </div>\n            <div class=\"line-item-buttons d-flex justify-content-end mt-1\">\n                <scrm-button *ngIf=\"isEditable()\" [config]=\"getAddItemButton()\">\n                </scrm-button>\n            </div>\n\n        </div>\n\n        <ng-container *ngIf=\"(mode === 'edit' || mode === 'filter') && field.itemFormArray && field.itemFormArray.errors\">\n            <ng-container *ngIf=\"field.itemFormArray.invalid\">\n                <div *ngFor=\"let item of field.itemFormArray.errors | keyvalue\" class=\"invalid-feedback d-block\">\n                    <scrm-dynamic-label [context]=\"getMessageContext(item.value, record)\"\n                                        [fields]=\"{field: field}\"\n                                        [labelKey]=\"getMessageLabelKey(item.value)\">\n                    </scrm-dynamic-label>\n                </div>\n            </ng-container>\n        </ng-container>\n    </ng-container>\n\n\n    <ng-container *ngIf=\"field.loading\">\n        <div class= \"dynamic-field\">\n            <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"></div>\n        </div>\n    </ng-container>\n\n</ng-container>\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldRegistry }, { type: RecordManager }, { type: FieldLogicManager }, { type: FieldManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FieldComponent_ng_container_0_scrm_dynamic_field_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-dynamic-field", 3);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("componentType", ctx_r1.componentType)("field", ctx_r1.field)("klass", ctx_r1.klass)("mode", ctx_r1.componentMode)("originalMode", ctx_r1.mode)("record", ctx_r1.record)("parent", ctx_r1.record)("type", ctx_r1.type);
} }
function FieldComponent_ng_container_0_scrm_line_items_field_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-line-items-field", 4);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("field", ctx_r2.field)("klass", ctx_r2.klass)("mode", ctx_r2.componentMode)("originalMode", ctx_r2.mode)("record", ctx_r2.record)("parent", ctx_r2.record);
} }
function FieldComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, FieldComponent_ng_container_0_scrm_dynamic_field_1_Template, 1, 8, "scrm-dynamic-field", 1);
    i0.ɵɵtemplate(2, FieldComponent_ng_container_0_scrm_line_items_field_2_Template, 1, 6, "scrm-line-items-field", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.type !== "line-items");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.type === "line-items");
} }
class FieldComponent {
    constructor(registry) {
        this.registry = registry;
        this.record = null;
        this.klass = null;
        this.class = 'field';
        this.map = viewFieldsMap;
    }
    ngOnInit() {
        this.setHostClass();
    }
    get componentMode() {
        let mode = this.mode;
        if (mode === 'create') {
            mode = 'edit';
        }
        if (['edit', 'filter'].includes(mode) && this.field.readonly) {
            mode = 'detail';
        }
        return mode;
    }
    get componentType() {
        let module = (this.record && this.record.module) || 'default';
        const displayType = (this.field.definition && this.field.definition.displayType) || '';
        return this.registry.getDisplayType(module, this.type, displayType, this.componentMode, this.field.name);
    }
    setHostClass() {
        const classes = [];
        classes.push('field');
        if (this.mode) {
            classes.push('field-mode-' + this.mode);
        }
        if (this.type) {
            classes.push('field-type-' + this.type);
        }
        if (this.field && this.field.name) {
            classes.push('field-name-' + this.field.name);
        }
        this.class = classes.join(' ');
    }
    static { this.ɵfac = function FieldComponent_Factory(t) { return new (t || FieldComponent)(i0.ɵɵdirectiveInject(FieldRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FieldComponent, selectors: [["scrm-field"]], hostVars: 2, hostBindings: function FieldComponent_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵclassMap(ctx.class);
        } }, inputs: { mode: "mode", type: "type", field: "field", record: "record", klass: "klass" }, decls: 1, vars: 1, consts: [[4, "ngIf"], [3, "componentType", "field", "klass", "mode", "originalMode", "record", "parent", "type", 4, "ngIf"], [3, "field", "klass", "mode", "originalMode", "record", "parent", 4, "ngIf"], [3, "componentType", "field", "klass", "mode", "originalMode", "record", "parent", "type"], [3, "field", "klass", "mode", "originalMode", "record", "parent"]], template: function FieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, FieldComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.field && ctx.field.display !== "none");
        } }, dependencies: [i2.NgIf, DynamicFieldComponent, LineItemsComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldComponent, [{
        type: Component,
        args: [{ selector: 'scrm-field', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"field && field.display !== 'none'\">\n    <scrm-dynamic-field *ngIf=\"type !== 'line-items'\"\n                        [componentType]=\"componentType\"\n                        [field]=\"field\"\n                        [klass]=\"klass\"\n                        [mode]=\"componentMode\"\n                        [originalMode]=\"mode\"\n                        [record]=\"record\"\n                        [parent]=\"record\"\n                        [type]=\"type\">\n    </scrm-dynamic-field>\n    <scrm-line-items-field *ngIf=\"type === 'line-items'\"\n                           [field]=\"field\"\n                           [klass]=\"klass\"\n                           [mode]=\"componentMode\"\n                           [originalMode]=\"mode\"\n                           [record]=\"record\"\n                           [parent]=\"record\">\n    </scrm-line-items-field>\n</ng-container>\n\n" }]
    }], function () { return [{ type: FieldRegistry }]; }, { mode: [{
            type: Input,
            args: ['mode']
        }], type: [{
            type: Input,
            args: ['type']
        }], field: [{
            type: Input,
            args: ['field']
        }], record: [{
            type: Input,
            args: ['record']
        }], klass: [{
            type: Input,
            args: ['klass']
        }], class: [{
            type: HostBinding,
            args: ['class']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FieldGridComponent_div_1_div_1_div_2_label_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "label", 1);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r3 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", ctx_r8.labelClass);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(col_r3.field.label);
} }
function FieldGridComponent_div_1_div_1_div_2_scrm_label_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-label", 8);
} if (rf & 2) {
    const col_r3 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("labelKey", col_r3.field.labelKey)("ngClass", ctx_r9.labelClass);
} }
function FieldGridComponent_div_1_div_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, FieldGridComponent_div_1_div_1_div_2_label_1_Template, 2, 2, "label", 6);
    i0.ɵɵtemplate(2, FieldGridComponent_div_1_div_1_div_2_scrm_label_2_Template, 1, 2, "scrm-label", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r3 = i0.ɵɵnextContext().$implicit;
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("pr-3", ctx_r4.labelDisplay === "inline");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r3.field.label);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !col_r3.field.label && col_r3.field.labelKey);
} }
function FieldGridComponent_div_1_div_1_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "scrm-field", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r3 = i0.ɵɵnextContext().$implicit;
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("flex-grow-1", ctx_r5.labelDisplay === "inline");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("field", col_r3.field)("klass", ctx_r5.inputClass)("mode", ctx_r5.fieldMode)("record", ctx_r5.record)("type", col_r3.field.type);
} }
function FieldGridComponent_div_1_div_1_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵprojection(1);
    i0.ɵɵelementContainerEnd();
} }
function FieldGridComponent_div_1_div_1_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵprojection(1, 1);
    i0.ɵɵelementContainerEnd();
} }
function FieldGridComponent_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 2);
    i0.ɵɵtemplate(2, FieldGridComponent_div_1_div_1_div_2_Template, 3, 4, "div", 3);
    i0.ɵɵtemplate(3, FieldGridComponent_div_1_div_1_div_3_Template, 2, 7, "div", 4);
    i0.ɵɵtemplate(4, FieldGridComponent_div_1_div_1_ng_container_4_Template, 2, 0, "ng-container", 5);
    i0.ɵɵtemplate(5, FieldGridComponent_div_1_div_1_ng_container_5_Template, 2, 0, "ng-container", 5);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const col_r3 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", ctx_r2.colClass);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("align-items-center", ctx_r2.labelDisplay === "inline" && !ctx_r2.colAlignItems)("flex-column", ctx_r2.labelDisplay === "top")("flex-row", ctx_r2.labelDisplay === "inline")("justify-content-end", !col_r3.field);
    i0.ɵɵproperty("ngClass", ctx_r2.colAlignItems ? ctx_r2.colAlignItems : "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r3.field && col_r3.field.display !== "none");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r3.field && col_r3.field.display !== "none");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r3.actionSlot);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r3.specialSlot);
} }
function FieldGridComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, FieldGridComponent_div_1_div_1_Template, 6, 14, "div", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const row_r1 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngClass", ctx_r0.rowClass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", row_r1.cols);
} }
const _c0$x = [[["", "field-grid-actions", ""]], [["", "field-grid-actions", ""]]];
const _c1$a = ["[field-grid-actions]", "[field-grid-actions]"];
class FieldGridComponent extends BaseFieldGridComponent {
    constructor(breakpointObserver) {
        super(breakpointObserver);
        this.breakpointObserver = breakpointObserver;
        this.fieldMode = 'detail';
    }
    ngOnChanges() {
        this.buildGrid();
    }
    buildGrid() {
        const grid = [];
        if (!this.fields || this.fields.length === 0) {
            this.fieldGrid = [];
            return;
        }
        let col = 0;
        let row = {
            cols: []
        };
        grid.push(row);
        this.fields.forEach(field => {
            if (col >= this.colNumber) {
                col = 0;
                row = {
                    cols: []
                };
                grid.push(row);
            }
            row.cols.push({
                field
            });
            col++;
        });
        const lastRow = grid[grid.length - 1];
        if (col < this.colNumber) {
            this.fillRow(lastRow);
        }
        this.addSpecialSlots(grid);
        this.fieldGrid = grid;
    }
    static { this.ɵfac = function FieldGridComponent_Factory(t) { return new (t || FieldGridComponent)(i0.ɵɵdirectiveInject(i1$1.BreakpointObserver)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FieldGridComponent, selectors: [["scrm-field-grid"]], inputs: { fields: "fields", record: "record", fieldMode: "fieldMode" }, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c1$a, decls: 2, vars: 1, consts: [[3, "ngClass", 4, "ngFor", "ngForOf"], [3, "ngClass"], [1, "d-flex", 3, "ngClass"], [3, "pr-3", 4, "ngIf"], [3, "flex-grow-1", 4, "ngIf"], [4, "ngIf"], [3, "ngClass", 4, "ngIf"], [3, "labelKey", "ngClass", 4, "ngIf"], [3, "labelKey", "ngClass"], [3, "field", "klass", "mode", "record", "type"]], template: function FieldGridComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$x);
            i0.ɵɵelementStart(0, "form");
            i0.ɵɵtemplate(1, FieldGridComponent_div_1_Template, 2, 2, "div", 0);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngForOf", ctx.fieldGrid);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, FieldComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldGridComponent, [{
        type: Component,
        args: [{ selector: 'scrm-field-grid', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<form>\n    <div [ngClass]=\"rowClass\" *ngFor=\"let row of fieldGrid\">\n\n        <div [ngClass]=\"colClass\" *ngFor=\"let col of row.cols\">\n            <div [class.align-items-center]=\"labelDisplay === 'inline' && !colAlignItems\"\n                     [class.flex-column]=\"labelDisplay === 'top'\"\n                     [class.flex-row]=\"labelDisplay === 'inline'\"\n                     [class.justify-content-end]=\"!col.field\"\n                     [ngClass]=\"colAlignItems ? colAlignItems : ''\"\n                     class=\"d-flex\"\n                >\n                    <div *ngIf=\"col.field && col.field.display !== 'none'\"\n                         [class.pr-3]=\"labelDisplay === 'inline'\" >\n                        <label *ngIf=\"col.field.label\" [ngClass]=\"labelClass\">{{col.field.label}}</label>\n                        <scrm-label *ngIf=\"!col.field.label && col.field.labelKey\"\n                                    [labelKey]=\"col.field.labelKey\"\n                                    [ngClass]=\"labelClass\"></scrm-label>\n                    </div>\n                    <div *ngIf=\"col.field && col.field.display !== 'none'\"\n                         [class.flex-grow-1]=\"labelDisplay === 'inline'\">\n                        <scrm-field [field]=\"col.field\"\n                                    [klass]=\"inputClass\"\n                                    [mode]=\"fieldMode\"\n                                    [record]=\"record\"\n                                    [type]=\"col.field.type\">\n                        </scrm-field>\n                    </div>\n                    <ng-container *ngIf=\"col.actionSlot\">\n                        <ng-content select=\"[field-grid-actions]\"></ng-content>\n                    </ng-container>\n                    <ng-container *ngIf=\"col.specialSlot\">\n                        <ng-content select=\"[field-grid-actions]\"></ng-content>\n                    </ng-container>\n                </div>\n        </div>\n    </div>\n</form>\n" }]
    }], function () { return [{ type: i1$1.BreakpointObserver }]; }, { fields: [{
            type: Input
        }], record: [{
            type: Input
        }], fieldMode: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineItemsModule {
    static { this.ɵfac = function LineItemsModule_Factory(t) { return new (t || LineItemsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LineItemsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule,
            DynamicFieldModule,
            ButtonModule,
            DynamicLabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineItemsModule, [{
        type: NgModule,
        args: [{
                declarations: [LineItemsComponent, BaseLineItemsComponent],
                exports: [
                    LineItemsComponent
                ],
                imports: [
                    CommonModule,
                    LabelModule,
                    DynamicFieldModule,
                    ButtonModule,
                    DynamicLabelModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LineItemsModule, { declarations: [LineItemsComponent, BaseLineItemsComponent], imports: [CommonModule,
        LabelModule,
        DynamicFieldModule,
        ButtonModule,
        DynamicLabelModule], exports: [LineItemsComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldModule {
    static { this.ɵfac = function FieldModule_Factory(t) { return new (t || FieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [fieldModules, CommonModule,
            DynamicFieldModule,
            LineItemsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    FieldComponent,
                ],
                exports: [
                    FieldComponent,
                ],
                imports: [
                    ...fieldModules,
                    CommonModule,
                    DynamicFieldModule,
                    LineItemsModule
                ],
                schemas: [CUSTOM_ELEMENTS_SCHEMA]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FieldModule, { declarations: [FieldComponent], imports: [VarcharDetailFieldModule, VarcharEditFieldModule, VarcharFilterFieldModule, PasswordDetailFieldModule, PasswordEditFieldModule, IntDetailFieldModule, IconListFieldModule, FileDetailFieldModule, FloatDetailFieldModule, PhoneDetailFieldModule, DateDetailFieldModule, DateEditFieldModule, DateFilterFieldModule, DateTimeDetailFieldModule, DateTimeEditFieldModule, DateTimeFilterFieldModule, UrlDetailFieldModule, CurrencyDetailFieldModule, EmailListFieldsModule, TextDetailFieldModule, TextEditFieldModule, TextListFieldModule, RelateDetailFieldsModule, RelateEditFieldModule, RelateFilterFieldModule, FullNameDetailFieldsModule, EnumDetailFieldModule, EnumEditFieldModule, DropdownEnumDetailFieldModule, DropdownEnumEditFieldModule, RadioEnumDetailFieldModule, RadioEnumEditFieldModule, MultiEnumDetailFieldModule, MultiEnumEditFieldModule, MultiEnumFilterFieldModule, BooleanDetailFieldModule, BooleanEditFieldModule, HtmlDetailFieldModule, TinymceDetailFieldModule, TinymceEditFieldModule, GroupFieldModule, CompositeModule, CommonModule,
        DynamicFieldModule,
        LineItemsModule], exports: [FieldComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldGridModule {
    static { this.ɵfac = function FieldGridModule_Factory(t) { return new (t || FieldGridModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FieldGridModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            FieldModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldGridModule, [{
        type: NgModule,
        args: [{
                declarations: [FieldGridComponent],
                exports: [
                    FieldGridComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    FieldModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FieldGridModule, { declarations: [FieldGridComponent], imports: [CommonModule,
        ButtonModule,
        FieldModule,
        LabelModule], exports: [FieldGridComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FieldLayoutComponent_div_1_div_1_ng_container_1_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "span", 10);
    i0.ɵɵtext(2, "*");
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function FieldLayoutComponent_div_1_div_1_ng_container_1_ng_container_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵelement(2, "scrm-action-group-menu", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r4 = i0.ɵɵnextContext(2).$implicit;
    let tmp_1_0;
    let tmp_2_0;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", col_r4.adaptor)("buttonGroupClass", (tmp_1_0 = col_r4.fieldActions == null ? null : col_r4.fieldActions.containerKlass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "")("klass", (tmp_2_0 = col_r4.fieldActions == null ? null : col_r4.fieldActions.klass) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "");
} }
function FieldLayoutComponent_div_1_div_1_ng_container_1_button_13_Template(rf, ctx) { if (rf & 1) {
    const _r16 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 12);
    i0.ɵɵlistener("click", function FieldLayoutComponent_div_1_div_1_ng_container_1_button_13_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r15.dataSource.getEditAction()); });
    i0.ɵɵelement(1, "scrm-image", 13);
    i0.ɵɵelementEnd();
} }
const _c0$w = function () { return ["edit", "create"]; };
const _c1$9 = function (a0) { return { "align-items-center": a0 }; };
function FieldLayoutComponent_div_1_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 5)(2, "strong")(3, "label", 1);
    i0.ɵɵtext(4);
    i0.ɵɵpipe(5, "uppercase");
    i0.ɵɵelementEnd();
    i0.ɵɵtext(6, ": ");
    i0.ɵɵtemplate(7, FieldLayoutComponent_div_1_div_1_ng_container_1_ng_container_7_Template, 3, 0, "ng-container", 3);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(8, "div", 6)(9, "div", 7);
    i0.ɵɵelement(10, "scrm-field", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(11, FieldLayoutComponent_div_1_div_1_ng_container_1_ng_container_11_Template, 3, 3, "ng-container", 3);
    i0.ɵɵelementStart(12, "div");
    i0.ɵɵtemplate(13, FieldLayoutComponent_div_1_div_1_ng_container_1_button_13_Template, 2, 0, "button", 9);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r4 = i0.ɵɵnextContext().$implicit;
    const ctx_r6 = i0.ɵɵnextContext(2);
    let tmp_9_0;
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngClass", ctx_r6.labelClass);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(5, 11, col_r4.field.label));
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", col_r4.field.definition.required && i0.ɵɵpureFunction0(13, _c0$w).includes(ctx_r6.config.mode));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(14, _c1$9, (col_r4 == null ? null : col_r4.fieldActions) && (col_r4 == null ? null : col_r4.fieldActions == null ? null : col_r4.fieldActions.position) === "inline"));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("type", col_r4.field.type)("mode", ctx_r6.config.mode)("klass", ctx_r6.inputClass)("field", col_r4.field)("record", ctx_r6.record);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (col_r4 == null ? null : col_r4.fieldActions) && ((tmp_9_0 = col_r4 == null ? null : col_r4.fieldActions == null ? null : col_r4.fieldActions.position) !== null && tmp_9_0 !== undefined ? tmp_9_0 : "inline") === "inline");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", col_r4.field.definition.inline_edit !== false && !col_r4.field.readonly && !col_r4.field.definition.readonly && ctx_r6.dataSource.inlineEdit && ctx_r6.config.mode === "detail");
} }
function FieldLayoutComponent_div_1_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-action-group-menu", 11);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r4 = i0.ɵɵnextContext().$implicit;
    let tmp_1_0;
    let tmp_2_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", col_r4.adaptor)("buttonGroupClass", (tmp_1_0 = col_r4.fieldActions == null ? null : col_r4.fieldActions.containerKlass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "")("klass", (tmp_2_0 = col_r4.fieldActions == null ? null : col_r4.fieldActions.klass) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "");
} }
function FieldLayoutComponent_div_1_div_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵprojection(1);
    i0.ɵɵelementContainerEnd();
} }
function FieldLayoutComponent_div_1_div_1_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵprojection(1, 1);
    i0.ɵɵelementContainerEnd();
} }
function FieldLayoutComponent_div_1_div_1_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 14);
} }
function FieldLayoutComponent_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, FieldLayoutComponent_div_1_div_1_ng_container_1_Template, 14, 16, "ng-container", 3);
    i0.ɵɵtemplate(2, FieldLayoutComponent_div_1_div_1_ng_container_2_Template, 2, 3, "ng-container", 3);
    i0.ɵɵtemplate(3, FieldLayoutComponent_div_1_div_1_ng_container_3_Template, 2, 0, "ng-container", 3);
    i0.ɵɵtemplate(4, FieldLayoutComponent_div_1_div_1_ng_container_4_Template, 2, 0, "ng-container", 3);
    i0.ɵɵtemplate(5, FieldLayoutComponent_div_1_div_1_div_5_Template, 1, 0, "div", 4);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r4 = ctx.$implicit;
    const colNumber_r5 = ctx.index;
    const ctx_r19 = i0.ɵɵnextContext();
    const row_r1 = ctx_r19.$implicit;
    const i_r2 = ctx_r19.index;
    const ctx_r3 = i0.ɵɵnextContext();
    let tmp_3_0;
    i0.ɵɵclassProp("field-column-bordered", row_r1.cols.length > 1 && colNumber_r5 < row_r1.cols.length - 1);
    i0.ɵɵproperty("ngClass", ctx_r3.colClass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r4.field && col_r4.field.display !== "none");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (col_r4 == null ? null : col_r4.fieldActions) && ((tmp_3_0 = col_r4 == null ? null : col_r4.fieldActions == null ? null : col_r4.fieldActions.position) !== null && tmp_3_0 !== undefined ? tmp_3_0 : "inline") === "vertical");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r4.actionSlot);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r4.specialSlot);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r4.field && (col_r4.field == null ? null : col_r4.field.display) !== "none" && i_r2 < ctx_r3.fieldGrid.length - 1);
} }
function FieldLayoutComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, FieldLayoutComponent_div_1_div_1_Template, 6, 8, "div", 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const row_r1 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngClass", ctx_r0.rowClass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", row_r1.cols);
} }
const _c2$2 = [[["", "field-grid-actions", ""]], [["", "field-grid-special", ""]]];
const _c3$1 = ["[field-grid-actions]", "[field-grid-special]"];
class FieldLayoutComponent extends BaseFieldGridComponent {
    constructor(breakpointObserver) {
        super(breakpointObserver);
        this.breakpointObserver = breakpointObserver;
        this.baseColClass = {
            col: true,
            'form-group': true,
            'm-1': false,
            'm-0': true,
            'pl-3': true,
            'pb-2': true,
            'pr-3': true,
            'd-flex': true,
            'flex-column': true,
            'justify-content-between': true
        };
        this.baseRowClass = {
            'form-row': true,
            'align-items-stretch': true
        };
    }
    ngOnInit() {
        this.subscriptions.push(this.dataSource.getConfig().subscribe(config => {
            this.config = { ...config };
        }));
        this.subscriptions.push(this.dataSource.getLayout().subscribe(layout => {
            this.layout = { ...layout };
        }));
        this.subscriptions.push(this.dataSource.getFields().subscribe(fields => {
            this.fields = { ...fields };
        }));
        this.subscriptions.push(this.dataSource.getRecord().subscribe(record => {
            this.record = { ...record };
        }));
        super.ngOnInit();
    }
    buildGrid() {
        const grid = [];
        if (!this.fields || Object.keys(this.fields).length === 0) {
            this.fieldGrid = [];
            return;
        }
        this.layout.rows.forEach(layoutRow => {
            let row = {
                cols: []
            };
            layoutRow.cols.forEach((layoutCol, colIndex) => {
                const fieldName = layoutCol.name;
                const field = this.fields[fieldName] || null;
                const fieldActions = layoutCol.fieldActions || null;
                const adaptor = layoutCol.adaptor ?? null;
                if (!field) {
                    row.cols.push({});
                    return;
                }
                row.cols.push({
                    field,
                    fieldActions,
                    adaptor
                });
                if (this.colNumber === 1 && colIndex < layoutRow.cols.length - 1) {
                    grid.push(row);
                    row = {
                        cols: []
                    };
                }
            });
            if (row.cols.length < this.colNumber) {
                this.fillRow(row);
            }
            grid.push(row);
        });
        this.addSpecialSlots(grid);
        this.fieldGrid = grid;
    }
    get colNumber() {
        const size = this.sizeMap[this.currentSize];
        if (size === 1) {
            return 1;
        }
        return this.config.maxColumns;
    }
    static { this.ɵfac = function FieldLayoutComponent_Factory(t) { return new (t || FieldLayoutComponent)(i0.ɵɵdirectiveInject(i1$1.BreakpointObserver)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FieldLayoutComponent, selectors: [["scrm-field-layout"]], inputs: { dataSource: "dataSource" }, features: [i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c3$1, decls: 2, vars: 4, consts: [[3, "ngClass", 4, "ngFor", "ngForOf"], [3, "ngClass"], [3, "field-column-bordered", "ngClass", 4, "ngFor", "ngForOf"], [4, "ngIf"], ["class", "field-separation mt-2", 4, "ngIf"], [1, "label-container"], [1, "d-flex", "flex-grow-1", 3, "ngClass"], [1, "flex-grow-1", "text-break"], [3, "type", "mode", "klass", "field", "record"], ["type", "button", "class", "record-action-button", 3, "click", 4, "ngIf"], [1, "required"], [3, "config", "buttonGroupClass", "klass"], ["type", "button", 1, "record-action-button", 3, "click"], ["image", "pencil", 1, "sicon"], [1, "field-separation", "mt-2"]], template: function FieldLayoutComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c2$2);
            i0.ɵɵelementStart(0, "form");
            i0.ɵɵtemplate(1, FieldLayoutComponent_div_1_Template, 2, 2, "div", 0);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMapInterpolate1("field-layout ", ctx.config.mode, "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngForOf", ctx.fieldGrid);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, FieldComponent, ImageComponent, ActionGroupMenuComponent, i2.UpperCasePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLayoutComponent, [{
        type: Component,
        args: [{ selector: 'scrm-field-layout', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<form class=\"field-layout {{config.mode}}\">\n    <div [ngClass]=\"rowClass\" *ngFor=\"let row of fieldGrid; index as i\">\n\n        <div *ngFor=\"let col of row.cols; index as colNumber\"\n             [class.field-column-bordered]=\"row.cols.length > 1 && colNumber < row.cols.length - 1\"\n             [ngClass]=\"colClass\">\n\n            <ng-container *ngIf=\"col.field && col.field.display !== 'none'\">\n                <div class=\"label-container\">\n                    <strong>\n                        <label [ngClass]=\"labelClass\">{{col.field.label | uppercase}}</label>:\n                        <ng-container\n                            *ngIf=\"col.field.definition.required && (['edit', 'create'].includes(config.mode))\">\n                            <span class=\"required\">*</span>\n                        </ng-container>\n                    </strong>\n                </div>\n                <div class=\"d-flex flex-grow-1\"\n                    [ngClass]=\"{ 'align-items-center': (col?.fieldActions && col?.fieldActions?.position === 'inline') }\">\n                    <div class=\"flex-grow-1 text-break\">\n                        <scrm-field [type]=\"col.field.type\"\n                                    [mode]=\"config.mode\"\n                                    [klass]=\"inputClass\"\n                                    [field]=\"col.field\"\n                                    [record]=\"record\">\n                        </scrm-field>\n                    </div>\n\n                    <ng-container *ngIf=\"col?.fieldActions && ((col?.fieldActions?.position ?? 'inline') === 'inline')\">\n                        <div>\n                            <scrm-action-group-menu\n                                [config]=\"col.adaptor\"\n                                [buttonGroupClass] = \"col.fieldActions?.containerKlass ?? ''\"\n                                [klass] = \"col.fieldActions?.klass ?? ''\"\n                            >\n                            </scrm-action-group-menu>\n                        </div>\n                    </ng-container>\n\n                    <div>\n                        <button type=\"button\" class=\"record-action-button\"\n                                (click)=\"this.dataSource.getEditAction()\"\n                                *ngIf=\"col.field.definition.inline_edit !== false && !col.field.readonly && !col.field.definition.readonly && this.dataSource.inlineEdit && config.mode === 'detail'\">\n                            <scrm-image class=\"sicon\" image=\"pencil\"></scrm-image>\n                        </button>\n                    </div>\n                </div>\n            </ng-container>\n\n            <ng-container *ngIf=\"col?.fieldActions && ((col?.fieldActions?.position ?? 'inline' ) === 'vertical')\">\n                <scrm-action-group-menu\n                    [config]=\"col.adaptor\"\n                    [buttonGroupClass]=\"col.fieldActions?.containerKlass ?? ''\"\n                    [klass] = \"col.fieldActions?.klass ?? ''\"\n                >\n                </scrm-action-group-menu>\n            </ng-container>\n\n            <ng-container *ngIf=\"col.actionSlot\">\n                <ng-content select=\"[field-grid-actions]\"></ng-content>\n            </ng-container>\n\n            <ng-container *ngIf=\"col.specialSlot\">\n                <ng-content select=\"[field-grid-special]\"></ng-content>\n            </ng-container>\n\n            <div *ngIf=\"col.field && col.field?.display !== 'none' && i < fieldGrid.length - 1\"\n                 class=\"field-separation mt-2\">\n            </div>\n        </div>\n    </div>\n</form>\n" }]
    }], function () { return [{ type: i1$1.BreakpointObserver }]; }, { dataSource: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldLayoutModule {
    static { this.ɵfac = function FieldLayoutModule_Factory(t) { return new (t || FieldLayoutModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FieldLayoutModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            FieldGridModule,
            ImageModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldLayoutModule, [{
        type: NgModule,
        args: [{
                declarations: [FieldLayoutComponent],
                exports: [
                    FieldLayoutComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    FieldGridModule,
                    ImageModule,
                    ActionGroupMenuModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FieldLayoutModule, { declarations: [FieldLayoutComponent], imports: [CommonModule,
        FieldModule,
        FieldGridModule,
        ImageModule,
        ActionGroupMenuModule], exports: [FieldLayoutComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$g = {
    tabs: [],
    groupedTabs: [],
    modules: {},
    userActionMenu: [],
    quickActions: [],
    maxTabs: 0
};
let internalState$4 = deepClone(initialState$g);
let cache$$4 = null;
class NavigationStore {
    constructor(recordGQL) {
        this.recordGQL = recordGQL;
        this.store = new BehaviorSubject(internalState$4);
        this.state$ = this.store.asObservable();
        this.resourceName = 'navbar';
        this.fieldsMetadata = {
            fields: [
                'tabs',
                'groupedTabs',
                'modules',
                'userActionMenu',
                'maxTabs'
            ]
        };
        this.tabs$ = this.state$.pipe(map(state => state.tabs), distinctUntilChanged());
        this.groupedTabs$ = this.state$.pipe(map(state => state.groupedTabs), distinctUntilChanged());
        this.modules$ = this.state$.pipe(map(state => state.modules), distinctUntilChanged());
        this.userActionMenu$ = this.state$.pipe(map(state => state.userActionMenu), distinctUntilChanged());
        this.maxTabs$ = this.state$.pipe(map(state => state.maxTabs), distinctUntilChanged());
        this.quickActions$ = this.state$.pipe(map(state => state.quickActions), distinctUntilChanged());
        this.vm$ = this.tabs$.pipe(combineLatestWith(this.groupedTabs$, this.modules$, this.userActionMenu$, this.maxTabs$, this.quickActions$), map(([tabs, groupedTabs, modules, userActionMenu, maxTabs, quickActions]) => ({
            tabs, groupedTabs, modules, userActionMenu, maxTabs, quickActions
        })));
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        cache$$4 = null;
        this.updateState(deepClone(initialState$g));
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Initial Navigation load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @returns {{}} Observable<any>
     */
    load() {
        return this.getNavigation().pipe(tap(navigation => {
            this.updateState({
                ...internalState$4,
                tabs: navigation.tabs,
                groupedTabs: navigation.groupedTabs,
                userActionMenu: navigation.userActionMenu,
                modules: navigation.modules,
                maxTabs: navigation.maxTabs,
                quickActions: navigation?.quickActions ?? []
            });
        }));
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$4 !== null;
    }
    /**
     * Set pre-loaded navigation and cache
     */
    set(navigation) {
        cache$$4 = of(navigation).pipe(shareReplay(1));
        this.updateState({
            ...internalState$4,
            tabs: navigation.tabs,
            groupedTabs: navigation.groupedTabs,
            userActionMenu: navigation.userActionMenu,
            modules: navigation.modules,
            maxTabs: navigation.maxTabs,
            quickActions: navigation?.quickActions ?? []
        });
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {{}} state to set
     */
    updateState(state) {
        this.store.next(internalState$4 = state);
    }
    /**
     * Get Navigation cached Observable or call the backend
     *
     * @returns {{}} Observable<any>
     */
    getNavigation() {
        const user = '1';
        if (cache$$4 === null) {
            cache$$4 = this.fetch(user).pipe(shareReplay(1));
        }
        return cache$$4;
    }
    /**
     * Fetch the Navigation from the backend
     *
     * @param {string} userId to use
     * @returns {{}} Observable<any>
     */
    fetch(userId) {
        return this.recordGQL
            .fetch(this.resourceName, `/api/navbars/${userId}`, this.fieldsMetadata)
            .pipe(map(({ data }) => {
            let navigation = null;
            if (data && data.navbar) {
                navigation = {
                    tabs: data.navbar.tabs,
                    groupedTabs: data.navbar.groupedTabs,
                    userActionMenu: data.navbar.userActionMenu,
                    modules: data.navbar.modules,
                    maxTabs: data.navbar.maxTabs,
                    quickActions: data?.navbar?.quickActions ?? [],
                };
            }
            return navigation;
        }));
    }
    static { this.ɵfac = function NavigationStore_Factory(t) { return new (t || NavigationStore)(i0.ɵɵinject(EntityGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NavigationStore, factory: NavigationStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NavigationStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$f = {
    adminPanel: []
};
let internalState$3 = deepClone(initialState$f);
let cache$$3 = null;
class AdminMetadataStore {
    constructor(appStateStore) {
        this.appStateStore = appStateStore;
        this.store = new BehaviorSubject(internalState$3);
        this.state$ = this.store.asObservable();
        this.adminPanel$ = this.state$.pipe(map(state => state.adminPanel), distinctUntilChanged());
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        cache$$3 = null;
        this.updateState(deepClone(initialState$f));
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Returns the currently active admin panel
     *
     * @returns {object} the admin panel
     */
    getAdminPanel() {
        return internalState$3.adminPanel;
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$3 !== null;
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState$3 = state);
    }
    /**
     * Set pre-loaded adminMetadata and cache
     */
    set(adminMetadata) {
        cache$$3 = of(adminMetadata).pipe(shareReplay(1));
        this.updateState(adminMetadata);
    }
    static { this.ɵfac = function AdminMetadataStore_Factory(t) { return new (t || AdminMetadataStore)(i0.ɵɵinject(AppStateStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AdminMetadataStore, factory: AdminMetadataStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminMetadataStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$e = {
    globalRecentlyViewed: []
};
let internalState$2 = deepClone(initialState$e);
let cache$$2 = null;
class GlobalRecentlyViewedStore {
    constructor() {
        this.store = new BehaviorSubject(internalState$2);
        this.state$ = this.store.asObservable();
        this.globalRecentlyViewed$ = this.state$.pipe(map(state => state.globalRecentlyViewed), distinctUntilChanged());
    }
    /**
     * Public Api
     */
    /**
     * Clear state
     */
    clear() {
        cache$$2 = null;
        this.updateState(deepClone(initialState$e));
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Returns the currently active globalRecentlyViewedMetadata
     *
     * @returns {object} the globalRecentlyViewedMetadata
     */
    getGlobalRecentlyViewed() {
        return internalState$2.globalRecentlyViewed;
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$$2 !== null;
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState$2 = state);
    }
    /**
     * Set pre-loaded globalRecentlyViewedMetadata and cache
     */
    set(globalRecentlyViewedMetadata) {
        cache$$2 = of(globalRecentlyViewedMetadata).pipe(shareReplay(1));
        this.updateState({ globalRecentlyViewed: globalRecentlyViewedMetadata });
    }
    addToState(data) {
        const currentList = this.getGlobalRecentlyViewed();
        const newList = currentList.filter((obj) => obj?.attributes?.item_id !== data?.attributes?.item_id);
        newList.unshift(data);
        this.updateState({ globalRecentlyViewed: newList });
    }
    static { this.ɵfac = function GlobalRecentlyViewedStore_Factory(t) { return new (t || GlobalRecentlyViewedStore)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GlobalRecentlyViewedStore, factory: GlobalRecentlyViewedStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GlobalRecentlyViewedStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$d = {
    systemConfig: false,
    userPreferences: false,
    appStrings: false,
    appListStrings: false,
    modStrings: false,
    themeImages: false,
    navigation: false,
    moduleMetadata: false,
    adminMetadata: false,
    globalRecentlyViewed: false
};
let internalState$1 = deepClone(initialState$d);
let cache$$1 = null;
class AppMetadataStore {
    constructor(recordGQL, metadata, language, themeImages, config, preferences, navigation, adminMetadataStore, globalRecentlyViewedStore) {
        this.recordGQL = recordGQL;
        this.metadata = metadata;
        this.language = language;
        this.themeImages = themeImages;
        this.config = config;
        this.preferences = preferences;
        this.navigation = navigation;
        this.adminMetadataStore = adminMetadataStore;
        this.globalRecentlyViewedStore = globalRecentlyViewedStore;
        this.store = new BehaviorSubject(internalState$1);
        this.state$ = this.store.asObservable();
        this.resourceName = 'appMetadata';
        this.fieldsMetadata = {
            fields: [
                'id',
                '_id',
            ]
        };
        this.types = [
            'systemConfig',
            'userPreferences',
            'language',
            'themeImages',
            'navigation',
            'moduleMetadata',
            'adminMetadata',
            'globalRecentlyViewed'
        ];
        this.metadata$ = this.state$;
    }
    /**
     * Clear state
     */
    clear() {
        cache$$1 = null;
        this.updateState(deepClone(initialState$d));
    }
    clearAuthBased() {
        this.clear();
    }
    get() {
        return internalState$1;
    }
    /**
     * Initial AppMetadata load if not cached and update state.
     *
     * @returns any data
     */
    load(module = 'login', types = [], useCache = true) {
        const notLoaded = this.getNotLoadedTypes();
        useCache = useCache && notLoaded.length < 1;
        if (!types || types.length < 1) {
            types = notLoaded;
            types.push('minimalModuleMetadata');
        }
        return this.getMetadata(module, types, useCache).pipe(tap((metadata) => {
            this.updateState(metadata);
        }));
    }
    /**
     * Initial AppMetadata load if not cached and update state.
     *
     * @returns any data
     */
    loadModuleMetadata(module = 'login', useCache = true) {
        let isLoaded = internalState$1?.moduleMetadata ?? false;
        useCache = useCache && isLoaded;
        return this.getMetadata(module, ['moduleMetadata'], useCache).pipe(tap((metadata) => {
            this.updateState(metadata);
        }));
    }
    /**
     * Get metadata cached Observable or call the backend
     *
     * @returns {object} Observable<AppMetadataFlags>
     */
    getMetadata(module = 'app', types = [], useCache = true) {
        if (!types || types.length < 1) {
            types = [...this.types];
        }
        if (cache$$1 == null || useCache !== true) {
            cache$$1 = this.fetch(module, types).pipe(shareReplay(1));
        }
        return cache$$1;
    }
    getNotLoadedTypes() {
        const types = [];
        if (!this.isNavigationLoaded()) {
            types.push('navigation');
        }
        if (!this.arePreferencesLoaded()) {
            types.push('userPreferences');
        }
        if (!this.areSystemConfigsLoaded()) {
            types.push('systemConfig');
        }
        if (!this.areAllLanguageStringsLoaded()) {
            types.push('language');
        }
        if (!this.areThemeImagesLoaded()) {
            types.push('themeImages');
        }
        if (!this.isAdminMetadataLoaded()) {
            types.push('adminMetadata');
        }
        if (!this.isGlobalRecentlyViewedLoaded()) {
            types.push('globalRecentlyViewed');
        }
        return types;
    }
    areAllLanguageStringsLoaded() {
        return this.language.areAllCached();
    }
    arePreferencesLoaded() {
        return this.preferences.isCached();
    }
    areSystemConfigsLoaded() {
        return this.config.isCached();
    }
    areThemeImagesLoaded() {
        return this.themeImages.isCached();
    }
    isNavigationLoaded() {
        return this.navigation.isCached();
    }
    isAdminMetadataLoaded() {
        return !!(internalState$1.adminMetadata ?? false);
    }
    isGlobalRecentlyViewedLoaded() {
        return !!(internalState$1.globalRecentlyViewed ?? false);
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState$1 = state);
    }
    /**
     * Fetch the Metadata from the backend
     *
     * @returns {object} Observable<{}>
     */
    fetch(module, types = []) {
        const fieldsToRetrieve = {
            fields: [
                ...this.fieldsMetadata.fields,
                ...types
            ]
        };
        return this.recordGQL.fetch(this.resourceName, `/api/app-metadata/${module}`, fieldsToRetrieve)
            .pipe(catchError(() => {
            return of({});
        }), map(({ data }) => {
            const result = data?.appMetadata;
            const appMetadata = { ...internalState$1 };
            if (emptyObject(result)) {
                return appMetadata;
            }
            this.setConfig(appMetadata, result);
            this.setPreferences(appMetadata, result);
            this.setThemeImages(appMetadata, result);
            this.setNavigation(appMetadata, result);
            this.setLanguages(appMetadata, result);
            this.setModuleMetadata(appMetadata, result);
            this.setAdminMetadata(appMetadata, result);
            this.setGlobalRecentlyViewed(appMetadata, result);
            return appMetadata;
        }));
    }
    setModuleMetadata(currentMetadata, appMetadata) {
        let moduleMetadata = appMetadata?.moduleMetadata ?? {};
        let metaKey = 'moduleMetadata';
        if (emptyObject(moduleMetadata)) {
            moduleMetadata = appMetadata?.minimalModuleMetadata ?? {};
            metaKey = 'minimalModuleMetadata';
        }
        if (!emptyObject(moduleMetadata)) {
            currentMetadata[metaKey] = true;
            Object.keys(moduleMetadata).forEach(module => {
                const meta = moduleMetadata[module] ?? {};
                if (!emptyObject(meta)) {
                    const parsedMeta = this.metadata.mapMetadata(module, moduleMetadata[module]);
                    if (this.metadata.getModule() !== module) {
                        this.metadata.setModuleMetadata(module, parsedMeta);
                    }
                    else if (!this.metadata.isCached(module)) {
                        this.metadata.set(module, parsedMeta);
                    }
                }
            });
        }
    }
    setLanguages(currentMetadata, appMetadata) {
        const lang = appMetadata?.language ?? {};
        if (!emptyObject(lang)) {
            const languageStrings = {};
            languageStrings.languageKey = lang.id ?? '';
            languageStrings.appStrings = lang?.appStrings?.items ?? {};
            languageStrings.appListStrings = lang?.appListStrings?.items ?? {};
            languageStrings.modStrings = lang?.modStrings?.items ?? {};
            currentMetadata.appStrings = !emptyObject(languageStrings.appStrings);
            currentMetadata.appListStrings = !emptyObject(languageStrings.appListStrings);
            currentMetadata.modStrings = !emptyObject(languageStrings.modStrings);
            this.language.set(languageStrings.languageKey, languageStrings);
        }
    }
    setNavigation(currentMetadata, appMetadata) {
        const navigation = appMetadata?.navigation ?? {};
        if (!emptyObject(navigation)) {
            currentMetadata.navigation = true;
            this.navigation.set(navigation);
        }
    }
    setThemeImages(currentMetadata, appMetadata) {
        const themeImages = appMetadata?.themeImages ?? {};
        const images = themeImages?.items ?? {};
        if (!emptyObject(themeImages) && !emptyObject(images)) {
            currentMetadata.themeImages = true;
            const theme = themeImages.id;
            this.themeImages.set(theme, images);
        }
    }
    setPreferences(currentMetadata, appMetadata) {
        const prefs = appMetadata?.userPreferences ?? {};
        if (!emptyObject(prefs)) {
            currentMetadata.userPreferences = true;
            const userPreferences = this.mapPreferences(prefs);
            this.preferences.set(userPreferences);
        }
    }
    setConfig(currentMetadata, appMetadata) {
        const configs = appMetadata?.systemConfig ?? {};
        if (!emptyObject(configs)) {
            currentMetadata.systemConfig = true;
            this.config.set(configs);
        }
    }
    setAdminMetadata(currentMetadata, appMetadata) {
        const adminMetadata = appMetadata?.adminMetadata ?? {};
        if (!emptyObject(adminMetadata)) {
            currentMetadata.adminMetadata = true;
            this.adminMetadataStore.set(adminMetadata);
        }
    }
    setGlobalRecentlyViewed(currentMetadata, appMetadata) {
        const globalRecentlyViewed = appMetadata?.globalRecentlyViewed ?? [];
        if (globalRecentlyViewed.length) {
            currentMetadata.globalRecentlyViewed = true;
            this.globalRecentlyViewedStore.set(globalRecentlyViewed);
        }
        else if (appMetadata?.globalRecentlyViewed) {
            this.globalRecentlyViewedStore.set(globalRecentlyViewed);
        }
    }
    mapPreferences(preferences) {
        const userPreferences = {};
        Object.keys(preferences).forEach((prefKey) => {
            if (!preferences[prefKey].items) {
                return;
            }
            Object.keys(preferences[prefKey].items).forEach(key => {
                userPreferences[key] = preferences[prefKey].items[key];
            });
        });
        return userPreferences;
    }
    static { this.ɵfac = function AppMetadataStore_Factory(t) { return new (t || AppMetadataStore)(i0.ɵɵinject(EntityGQL), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(AdminMetadataStore), i0.ɵɵinject(GlobalRecentlyViewedStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppMetadataStore, factory: AppMetadataStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppMetadataStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: EntityGQL }, { type: MetadataStore }, { type: LanguageStore }, { type: ThemeImagesStore }, { type: SystemConfigStore }, { type: UserPreferenceStore }, { type: NavigationStore }, { type: AdminMetadataStore }, { type: GlobalRecentlyViewedStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StateManager {
    constructor(appStore, languageStore, metadataStore, navigationStore, systemConfigStore, themeImagesStore, userPreferenceStore, appMetadataStore) {
        this.appStore = appStore;
        this.languageStore = languageStore;
        this.metadataStore = metadataStore;
        this.navigationStore = navigationStore;
        this.systemConfigStore = systemConfigStore;
        this.themeImagesStore = themeImagesStore;
        this.userPreferenceStore = userPreferenceStore;
        this.appMetadataStore = appMetadataStore;
        this.stateStores = {};
        this.stateStores.appStore = this.buildMapEntry(appStore, false);
        this.stateStores.navigationStore = this.buildMapEntry(navigationStore, true);
        this.stateStores.languageStore = this.buildMapEntry(languageStore, true);
        this.stateStores.metadataStore = this.buildMapEntry(metadataStore, false);
        this.stateStores.systemConfigStore = this.buildMapEntry(systemConfigStore, false);
        this.stateStores.themeImagesStore = this.buildMapEntry(themeImagesStore, false);
        this.stateStores.userPreferenceStore = this.buildMapEntry(userPreferenceStore, true);
        this.stateStores.appMetadataStore = this.buildMapEntry(appMetadataStore, true);
    }
    /**
     * Public Api
     */
    /**
     * Clear all state
     */
    clear() {
        Object.keys(this.stateStores).forEach((key) => {
            this.stateStores[key].store.clear();
        });
    }
    /**
     * Clear all state
     */
    clearAuthBased() {
        Object.keys(this.stateStores).forEach((key) => {
            if (this.stateStores[key].authBased) {
                this.stateStores[key].store.clearAuthBased();
            }
        });
    }
    clearBackendCacheable() {
        this.clearAuthBased();
        this.systemConfigStore.clear();
    }
    /**
     * Internal api
     */
    /**
     * Build Map entry
     *
     * @param {{}} store to use
     * @param {boolean} authBased flag
     * @returns {{}} StateStoreMapEntry
     */
    buildMapEntry(store, authBased) {
        return {
            store,
            authBased
        };
    }
    static { this.ɵfac = function StateManager_Factory(t) { return new (t || StateManager)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StateManager, factory: StateManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StateManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AppStateStore }, { type: LanguageStore }, { type: MetadataStore }, { type: NavigationStore }, { type: SystemConfigStore }, { type: ThemeImagesStore }, { type: UserPreferenceStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2022 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseRouteService {
    constructor() {
    }
    /**
     * Calculate Base Route
     *
     * @returns {string}
     * @param url
     */
    calculateRoute(url) {
        const path = window.location.pathname;
        if (path.includes('index.php')) {
            url = `${path}/${url}`;
        }
        return url;
    }
    /**
     * Append auth path
     * @param url
     */
    appendNativeAuth(url) {
        const path = window.location.pathname;
        if (path.includes('auth')) {
            url = `auth/${url}`;
        }
        return url;
    }
    /**
     * Remove native auth from path name
     */
    removeNativeAuth() {
        let url = window.location.pathname;
        if (url.includes('/auth')) {
            url = url.replace('/auth', '/');
        }
        url = url.replace('//', '/');
        return url;
    }
    /**
     * Is native auth
     */
    isNativeAuth() {
        const path = window.location.pathname;
        return path.includes('auth');
    }
    /**
     * Get native auth logout url
     */
    getNativeOutLogoutUrl() {
        return `auth/logout`;
    }
    /**
     * Is logged out page
     */
    isLoggedOutPath() {
        const path = window.location.pathname;
        return path.includes('logged-out');
    }
    static { this.ɵfac = function BaseRouteService_Factory(t) { return new (t || BaseRouteService)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseRouteService, factory: BaseRouteService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseRouteService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordStoreList {
    constructor(listStoreFactory, recordStoreFactory) {
        this.listStoreFactory = listStoreFactory;
        this.recordStoreFactory = recordStoreFactory;
        this.subs = [];
        this.stores = [];
        this.storeSubject = new BehaviorSubject([]);
        this.state$ = this.storeSubject.asObservable();
        this.pageSize = 10;
        this.recordList = listStoreFactory.create();
        this.stores$ = this.state$;
        this.storesMap$ = this.stores$.pipe(map(stores => {
            return this.getStoreMap(stores);
        }));
    }
    clear() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    clearAuthBased() {
    }
    getItemMetadata() {
        return null;
    }
    getRecordList() {
        return this.recordList;
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {boolean} load
     * @param {number} pageSize
     */
    init(module, load = true, pageSize = null) {
        let pageSizeConfigKey = 'list_max_entries_per_record_thread';
        if (pageSize && isFinite(pageSize)) {
            pageSizeConfigKey = '';
            this.recordList.setPageSize(pageSize);
        }
        const load$ = this.recordList.init(module, load, pageSizeConfigKey);
        this.pageSize = this.recordList.getPageSize();
        this.subs.push(this.recordList.records$.subscribe(records => {
            this.initStores(records);
        }));
        if (!load$) {
            return;
        }
        load$.pipe(tap((recordList) => {
            this.initStores(recordList.records);
        })).pipe(take(1)).subscribe();
        this.module = module;
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordList>
     */
    load(useCache = true) {
        return this.recordList.load(useCache).pipe(tap((recordList) => {
            this.initStores(recordList.records);
        }));
    }
    /**
     * Init record stores using records
     * @param records
     */
    initStores(records) {
        if (!records) {
            return;
        }
        const newStores = {};
        const storesArray = [];
        const storesMap = this.getStoreMap(this.stores);
        records.forEach(record => {
            if (!record || !record.id) {
                return;
            }
            const id = record.id;
            if (storesMap[id]) {
                const store = storesMap[id];
                store.setRecord(record);
                newStores[id] = store;
                storesArray.push(store);
                return;
            }
            newStores[id] = this.recordStoreFactory.create();
            if (this.getItemMetadata()) {
                newStores[id].setMetadata(this.getItemMetadata());
            }
            newStores[id].initRecord(record, 'detail', false);
            storesArray.push(newStores[id]);
        });
        const existingIds = Object.keys(storesMap);
        existingIds.forEach(id => {
            if (newStores[id]) {
                return;
            }
            storesMap[id].destroy();
        });
        this.updateState(storesArray);
    }
    updateState(stores) {
        this.storeSubject.next(this.stores = stores);
    }
    getStoreMap(stores) {
        const map = {};
        if (!stores || !stores.length) {
            return map;
        }
        stores.forEach(store => {
            map[store.getBaseRecord().id] = store;
        });
        return map;
    }
    getItemStores() {
        const stores = this.stores ?? [];
        if (stores && stores.length) {
            return stores;
        }
        return [];
    }
    getRecordIds() {
        const ids = [];
        if (!this.stores || !this.stores.length) {
            return ids;
        }
        this.stores.forEach(store => {
            ids.push(store.getRecordId());
        });
        return ids;
    }
    static { this.ɵfac = function RecordStoreList_Factory(t) { i0.ɵɵinvalidFactory(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordStoreList, factory: RecordStoreList.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordStoreList, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }, { type: undefined }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$c = {
    module: '',
    recordId: '',
    loading: {
        data: false,
        metadata: false
    },
    mode: 'detail',
};
class BaseRecordContainerStore {
    constructor(appStateStore, meta, message, fieldManager, language, storeFactory) {
        this.appStateStore = appStateStore;
        this.meta = meta;
        this.message = message;
        this.fieldManager = fieldManager;
        this.language = language;
        this.storeFactory = storeFactory;
        /** Internal Properties */
        this.internalState = deepClone(initialState$c);
        this.metadataState = deepClone({});
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.metadataStore = new BehaviorSubject({});
        this.metadataState$ = this.metadataStore.asObservable();
        this.subs = [];
        this.meta$ = this.metadataState$;
        this.recordStore = storeFactory.create(this.getViewFields$());
        this.record$ = this.recordStore.state$.pipe(distinctUntilChanged());
        this.stagingRecord$ = this.recordStore.staging$.pipe(distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading.data || state.loading.metadata));
        this.mode$ = this.state$.pipe(map(state => state.mode));
        this.vm$ = this.state$;
    }
    /**
     * Get current module name
     * @returns {string} module
     */
    getModuleName() {
        return this.internalState.module;
    }
    /**
     * Get current record id
     * @returns {string} id
     */
    getRecordId() {
        return this.internalState.recordId;
    }
    /**
     * Get View Context
     * @returns {object} ViewContext
     */
    getViewContext() {
        return {
            module: this.getModuleName(),
            id: this.getRecordId(),
        };
    }
    /**
     * Initial record load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {string} recordId to use
     * @param {string} mode to use
     * @returns {object} Observable<any>
     */
    init(module, recordId, mode = 'detail') {
        this.baseInit(module, recordId, mode);
        this.setMetadataLoading(true);
        const $data = forkJoin([this.loadMetadata(), this.load()]);
        return $data.pipe(map(([meta, record]) => record));
    }
    /**
     * Init record
     *
     * @param {object} record to use
     * @param {string} mode to use
     * @param {boolean} loadMetadata to use
     * @returns {object} Observable<any>
     */
    initRecord(record, mode = 'detail', loadMetadata = true) {
        this.baseInit(record.module, record.id, mode);
        if (loadMetadata) {
            this.loadMetadata().pipe(take(1), tap(() => {
                this.setRecord(record);
            })).subscribe();
        }
    }
    /**
     * Init staging
     * @param {object} record
     */
    initStaging(record) {
        const baseRecord = deepClone(this.recordStore.extractBaseRecord(record));
        this.recordStore.setStaging(baseRecord);
    }
    /**
     * Set Record
     * @param {object} record
     * @param {boolean} initDefaultValues
     */
    setRecord(record, initDefaultValues = false) {
        const baseRecord = deepClone(this.recordStore.extractBaseRecord(record));
        this.recordStore.setRecord(baseRecord, initDefaultValues);
    }
    /**
     * Set Metadata
     * @param {object} meta
     */
    setMetadata(meta) {
        this.updateMetadataState(meta);
        this.setMetadataLoading(false);
    }
    /**
     * Clean destroy
     */
    destroy() {
        this.clear();
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.updateState(deepClone(initialState$c));
        this.recordStore.destroy();
        this.recordStore = null;
    }
    /**
     * Clear observable cache
     */
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get staging record
     *
     * @returns {string} ViewMode
     */
    getBaseRecord() {
        return this.recordStore.getBaseRecord();
    }
    /**
     * Get current view mode
     *
     * @returns {string} ViewMode
     */
    getMode() {
        if (!this.internalState) {
            return null;
        }
        return this.internalState.mode;
    }
    /**
     * Set new mode
     *
     * @param {string} mode ViewMode
     */
    setMode(mode) {
        this.updateState({ ...this.internalState, mode });
    }
    /**
     * Set loading flag
     *
     * @param {boolean} loading flag
     */
    setDataLoading(loading) {
        this.updateState({
            ...this.internalState,
            loading: {
                ...this.internalState.loading,
                data: loading
            }
        });
    }
    /**
     * Set loading flag
     *
     * @param {boolean} loading flag
     */
    setMetadataLoading(loading) {
        this.updateState({
            ...this.internalState,
            loading: {
                ...this.internalState.loading,
                metadata: loading
            }
        });
    }
    /**
     * Save record
     */
    save() {
        this.setDataLoading(true);
        return this.recordStore.save().pipe(catchError(() => {
            this.message.addDangerMessageByKey('LBL_ERROR_SAVING');
            return of({});
        }), finalize(() => {
            this.setDataLoading(false);
        }));
    }
    /**
     * Validate search filter fields
     *
     * @returns {object} Observable<boolean>
     */
    validate() {
        return this.recordStore.validate();
    }
    /**
     * Load / reload record using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordViewState>
     */
    load(useCache = true) {
        this.setDataLoading(true);
        return this.recordStore.retrieveRecord(this.internalState.module, this.internalState.recordId, useCache).pipe(tap((data) => {
            this.updateState({
                ...this.internalState,
                recordId: data.id,
                module: data.module,
            });
        }), finalize(() => {
            this.setDataLoading(false);
        }));
    }
    /**
     * Load / reload record using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordViewState>
     */
    loadMetadata(useCache = true) {
        this.setMetadataLoading(true);
        return this.meta.getMetadata(this.internalState.module).pipe(map(metadata => metadata.recordView), tap((meta) => {
            this.updateMetadataState(meta);
        }), finalize(() => {
            this.setMetadataLoading(false);
        }));
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Update the metadata state
     *
     * @param {object} state to set
     */
    updateMetadataState(state) {
        this.metadataStore.next(this.metadataState = state);
    }
    /**
     * Get record view metadata
     *
     * @returns {object} metadata M
     */
    getMetadata() {
        return deepClone(this.metadataState);
    }
    /**
     * Base store initialization
     * @param module
     * @param recordId
     * @param mode
     */
    baseInit(module, recordId, mode = 'detail') {
        this.updateState({
            ...this.internalState,
            module,
            recordId,
            mode
        });
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$b = {
    id: '',
    type: '',
    module: '',
    attributes: {},
    acls: []
};
class RecordStore {
    constructor(definitions$, metadata$, recordSaveGQL, recordFetchGQL, message, recordManager, recordMappers) {
        this.definitions$ = definitions$;
        this.metadata$ = metadata$;
        this.recordSaveGQL = recordSaveGQL;
        this.recordFetchGQL = recordFetchGQL;
        this.message = message;
        this.recordManager = recordManager;
        this.recordMappers = recordMappers;
        this.initFieldDefaults = false;
        this.fieldDefaultsInitialized = false;
        this.cache$ = null;
        this.internalState = deepClone(initialState$b);
        this.stagingState = deepClone(initialState$b);
        this.store = new BehaviorSubject(this.internalState);
        this.staging = new BehaviorSubject(this.stagingState);
        this.definitions = [];
        this.metadata = null;
        this.subs = [];
        this.fieldsMetadata = {
            fields: [
                '_id',
                'id',
                'attributes',
                'module',
                'type',
                'acls',
                'favorite'
            ]
        };
        this.state$ = this.store.asObservable().pipe(distinctUntilChanged());
        this.staging$ = this.staging.asObservable();
        this.subs.push(this.state$.subscribe(record => {
            this.updateStaging(record);
        }));
        this.subs.push(definitions$.subscribe(definitions => {
            this.definitions = definitions;
            this.init(this.internalState);
        }));
        if (metadata$) {
            this.subs.push(metadata$.subscribe(metadata => {
                this.setMetadata(metadata);
            }));
        }
    }
    init(record, initDefaultValues = false) {
        const newRecord = {
            ...record,
        };
        this.initFieldDefaults = initDefaultValues;
        this.initRecord(newRecord);
        this.updateState(newRecord);
    }
    getStaging() {
        if (!this.stagingState) {
            return null;
        }
        return this.stagingState;
    }
    setStaging(record) {
        this.initRecord(record);
        this.staging.next(this.stagingState = record);
    }
    setRecord(record, initDefaultValues = false) {
        this.initFieldDefaults = initDefaultValues;
        this.initRecord(record);
        this.updateState(record);
    }
    save() {
        this.mapStagingFields();
        return this.recordSaveGQL.save(this.stagingState).pipe(tap((record) => {
            this.initRecord(record);
            this.updateState(record);
        }));
    }
    validate() {
        this.stagingState.formGroup.markAllAsTouched();
        this.stagingState?.validationTriggered.set(true);
        return this.stagingState.formGroup.statusChanges.pipe(startWith(this.stagingState.formGroup.status), filter(status => status !== 'PENDING'), take(1), map(status => status === 'VALID'));
    }
    resetStaging() {
        this.updateStaging(this.internalState);
    }
    destroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    /**
     * Get record
     *
     * @returns {object} Record
     */
    getBaseRecord() {
        if (!this.internalState) {
            return null;
        }
        const baseRecord = {
            id: this.internalState.id,
            type: this.internalState.type,
            module: this.internalState.module,
            attributes: this.internalState.attributes,
            acls: this.internalState.acls
        };
        return deepClone(baseRecord);
    }
    /**
     * Get record
     *
     * @returns {object} Record
     */
    getBaseStaging() {
        if (!this.stagingState) {
            return null;
        }
        this.mapStagingFields();
        const baseRecord = {
            id: this.stagingState.id,
            type: this.stagingState.type,
            module: this.stagingState.module,
            attributes: this.stagingState.attributes,
            acls: this.stagingState.acls
        };
        return deepClone(baseRecord);
    }
    /**
     * Extract base record
     *
     * @returns {object} Record
     */
    extractBaseRecord(record) {
        const { fields, formGroup, ...base } = record;
        return { ...base };
    }
    /**
     * Is staging record dirty
     *
     * @returns {object} Record
     */
    isDirty() {
        if (!this.stagingState || !this.stagingState.formGroup) {
            return false;
        }
        return this.stagingState.formGroup.dirty;
    }
    /**
     * Get record cached Observable or call the backend
     *
     * @param {string} module to use
     * @param {string} recordId to use
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<any>
     */
    retrieveRecord(module, recordId, useCache = true) {
        if (this.cache$ == null || useCache === false) {
            this.cache$ = this.fetch(module, recordId).pipe(tap(record => this.init(record)), shareReplay(1));
        }
        return this.cache$;
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Update the staging
     *
     * @param {object} state to set
     */
    updateStaging(state) {
        const newState = deepClone(this.extractBaseRecord(state));
        this.initRecord(newState, this.initFieldDefaults);
        this.staging.next(this.stagingState = newState);
    }
    /**
     * Map staging fields
     */
    mapStagingFields() {
        const mappers = this.recordMappers.get(this.stagingState.module);
        Object.keys(mappers).forEach(key => {
            const mapper = mappers[key];
            mapper.map(this.stagingState);
        });
    }
    /**
     * Init record fields
     *
     * @param {object} record Record
     * @param {boolean} initDefaultValues
     */
    initRecord(record, initDefaultValues = false) {
        if (this.metadata) {
            record.metadata = this.metadata;
        }
        if (!record?.validationTriggered) {
            record.validationTriggered = signal(false);
        }
        if (record.module && this.definitions && this.definitions.length > 0) {
            record.fields = this.recordManager.initFields(record, this.definitions);
        }
        if (initDefaultValues) {
            this.recordManager.initFieldDefaults(record);
            this.fieldDefaultsInitialized = true;
        }
    }
    /**
     * Fetch the record from the backend
     *
     * @param {string} module to use
     * @param {string} recordID to use
     * @returns {object} Observable<any>
     */
    fetch(module, recordID) {
        return this.recordFetchGQL.fetch(module, recordID, this.fieldsMetadata)
            .pipe(map(({ data }) => {
            const record = {
                type: '',
                module: '',
                attributes: {},
                acls: []
            };
            if (!data) {
                return record;
            }
            const id = data.record.attributes.id;
            if (!id) {
                this.message.addDangerMessageByKey('LBL_RECORD_DOES_NOT_EXIST');
                return record;
            }
            record.id = id;
            record.module = module;
            record.type = data.record.attributes && data.record.attributes.object_name;
            record.attributes = data.record.attributes;
            record.acls = data.record.acls;
            record.favorite = data?.record?.favorite ?? false;
            return record;
        }), catchError(err => throwError(err)));
    }
    setMetadata(metadata) {
        if (!metadata) {
            return;
        }
        this.metadata = metadata;
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordFetchGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Fetch data from backend
     *
     * @param {string} module name
     * @param {string} record id
     * @param {object} metadata with the fields to ask for
     * @returns {object} Observable<ApolloQueryResult<any>>
     */
    fetch(module, record, metadata) {
        const fields = metadata.fields;
        const queryOptions = {
            query: gql `
            query record($module: String!, $record: String!) {
                record(module: $module, record: $record) {
                    ${fields.join('\n')}
                }
            }
        `,
            variables: {
                module,
                record,
            },
        };
        return this.apollo.query(queryOptions);
    }
    static { this.ɵfac = function RecordFetchGQL_Factory(t) { return new (t || RecordFetchGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordFetchGQL, factory: RecordFetchGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordFetchGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordSaveGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Save record on the backend
     *
     * @param {object} record to save
     *
     * @returns {object} Observable<Record>
     */
    save(record) {
        const input = {
            module: record.module,
            attributes: deepClone(record.attributes),
        };
        if (record.id) {
            // eslint-disable-next-line no-underscore-dangle
            input._id = record.id;
        }
        const mutationOptions = {
            mutation: gql `
                mutation saveRecord($input: saveRecordInput!) {
                    saveRecord(input: $input) {
                        record {
                            attributes
                            favorite
                            id
                            _id
                            module
                            acls
                        }
                    }
                }
            `,
            variables: {
                input
            },
        };
        return this.apollo.mutate(mutationOptions).pipe(map((result) => this.mapToRecord(result)));
    }
    mapToRecord(response) {
        if (!response.data || !response.data.saveRecord || !response.data.saveRecord.record) {
            return null;
        }
        return {
            // eslint-disable-next-line no-underscore-dangle
            id: response.data.saveRecord.record._id,
            type: response?.data?.saveRecord?.record?.type ?? '',
            module: response?.data?.saveRecord?.record?.module ?? '',
            attributes: response?.data?.saveRecord?.record?.attributes ?? [],
            acls: response?.data?.saveRecord?.record?.acls ?? [],
            favorite: response?.data.saveRecord?.record?.favorite ?? false
        };
    }
    static { this.ɵfac = function RecordSaveGQL_Factory(t) { return new (t || RecordSaveGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordSaveGQL, factory: RecordSaveGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordSaveGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordStoreFactory {
    constructor(recordFetchGQL, recordSaveGQL, message, recordManager, recordMappers, baseMapper) {
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.message = message;
        this.recordManager = recordManager;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        recordMappers.register('default', baseMapper.getKey(), baseMapper);
    }
    create(definitions$, metadata$) {
        return new RecordStore(definitions$, metadata$, this.recordSaveGQL, this.recordFetchGQL, this.message, this.recordManager, this.recordMappers);
    }
    static { this.ɵfac = function RecordStoreFactory_Factory(t) { return new (t || RecordStoreFactory)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordManager), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordStoreFactory, factory: RecordStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: MessageService }, { type: RecordManager }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemStore extends BaseRecordContainerStore {
    constructor(appStateStore, meta, message, fieldManager, language, storeFactory) {
        super(appStateStore, meta, message, fieldManager, language, storeFactory);
        this.appStateStore = appStateStore;
        this.meta = meta;
        this.message = message;
        this.fieldManager = fieldManager;
        this.language = language;
        this.storeFactory = storeFactory;
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<ViewFieldDefinition[]>
     */
    getViewFields$() {
        return this.meta$.pipe(map((meta) => {
            const fieldsMap = {};
            const fields = [];
            const fieldDefinitions = meta.fields ?? {};
            Object.keys(fieldDefinitions).forEach(fieldName => {
                if (fieldDefinitions[fieldName]) {
                    fieldsMap[fieldName] = fieldDefinitions[fieldName];
                }
            });
            meta.headerLayout && meta.headerLayout.rows && meta.headerLayout.rows.forEach(row => {
                row.cols.forEach(col => {
                    if (col.field) {
                        fieldsMap[col.field.name] = col.field;
                    }
                });
            });
            meta.bodyLayout && meta.bodyLayout.rows && meta.bodyLayout.rows.forEach(row => {
                row.cols.forEach(col => {
                    if (col.field) {
                        fieldsMap[col.field.name] = col.field;
                    }
                });
            });
            Object.keys(fieldsMap).forEach(fieldName => {
                fields.push(fieldsMap[fieldName]);
            });
            return fields;
        }));
    }
    /**
     * Init record
     *
     * @param {object} record to use
     * @param {string} mode to use
     * @param {boolean} loadMetadata to use
     * @param initDefaultValues
     * @returns {object} Observable<any>
     */
    initRecord(record, mode = 'detail', loadMetadata = true, initDefaultValues = false) {
        super.initRecord(record, mode, loadMetadata);
        this.setRecord(record, initDefaultValues);
    }
    static { this.ɵfac = function RecordThreadItemStore_Factory(t) { return new (t || RecordThreadItemStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemStore, factory: RecordThreadItemStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemStore, [{
        type: Injectable
    }], function () { return [{ type: AppStateStore }, { type: MetadataStore }, { type: MessageService }, { type: FieldManager }, { type: LanguageStore }, { type: RecordStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemStoreFactory {
    constructor(appStateStore, meta, message, fieldManager, language, storeFactory) {
        this.appStateStore = appStateStore;
        this.meta = meta;
        this.message = message;
        this.fieldManager = fieldManager;
        this.language = language;
        this.storeFactory = storeFactory;
    }
    create() {
        return new RecordThreadItemStore(this.appStateStore, this.meta, this.message, this.fieldManager, this.language, this.storeFactory);
    }
    static { this.ɵfac = function RecordThreadItemStoreFactory_Factory(t) { return new (t || RecordThreadItemStoreFactory)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemStoreFactory, factory: RecordThreadItemStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AppStateStore }, { type: MetadataStore }, { type: MessageService }, { type: FieldManager }, { type: LanguageStore }, { type: RecordStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadStore extends RecordStoreList {
    constructor(listStoreFactory, recordStoreFactory) {
        super(listStoreFactory, recordStoreFactory);
        this.listStoreFactory = listStoreFactory;
        this.recordStoreFactory = recordStoreFactory;
        this.autoRefreshEnabled = true;
        this.$loading = this.recordList.loading$;
    }
    init(module, load = true, pageSize = null) {
        super.init(module, load, pageSize);
        this.autoRefreshEnabled = true;
    }
    setFilters(filters) {
        let criteria = this.recordList.criteria;
        criteria = {
            ...criteria,
            ...filters
        };
        if (filters && filters.orderBy) {
            let sortOrder = SortDirection.DESC;
            if (filters.sortOrder && String(filters.sortOrder).toUpperCase() === 'ASC') {
                sortOrder = SortDirection.ASC;
            }
            this.recordList.updateSorting(filters.orderBy, sortOrder, false);
        }
        this.recordList.updateSearchCriteria(criteria, false);
        return this.load(false).pipe(map(value => value.records));
    }
    getItemMetadata() {
        return this.itemMetadata;
    }
    getListMetadata() {
        return this.listMetadata;
    }
    setItemMetadata(meta) {
        return this.itemMetadata = meta;
    }
    setListMetadata(meta) {
        return this.listMetadata = meta;
    }
    allLoaded() {
        const pagination = this.recordList.getPagination();
        if (!pagination) {
            return false;
        }
        return pagination.pageSize >= pagination.total;
    }
    loadMore(jump = null) {
        if (!jump) {
            jump = this.pageSize;
        }
        const pagination = this.recordList.getPagination();
        const currentPageSize = pagination.pageSize || 0;
        let newPageSize = currentPageSize + jump;
        this.recordList.setPageSize(newPageSize);
        this.recordList.updatePagination(0);
    }
    reload() {
        this.recordList.updatePagination(0);
    }
    getViewContext() {
        return {
            module: this.module,
            ids: this.getRecordIds(),
        };
    }
    initAutoRefresh(autoRefreshFrequency, min, max, onRefresh) {
        const currentDate = new Date();
        const startOfNextMinute = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes() + 1);
        const autoRefreshTime = this.getAutoRefreshTime(autoRefreshFrequency, min, max);
        return timer(startOfNextMinute, autoRefreshTime).pipe(takeWhile(() => {
            return this.autoRefreshEnabled;
        }), tap(() => {
            this.load(false).subscribe(() => {
                if (onRefresh) {
                    onRefresh();
                }
            });
        }));
    }
    disableAutoRefresh() {
        this.autoRefreshEnabled = false;
    }
    getAutoRefreshTime(autoRefreshFrequency, min, max) {
        let autoRefreshTime = (autoRefreshFrequency * (60000));
        if (min === 0 && max === 0) {
            return autoRefreshTime;
        }
        return autoRefreshTime + this.getRandomDeviation(min, max);
    }
    getRandomDeviation(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min + 1) + min) * 1000;
    }
    static { this.ɵfac = function RecordThreadStore_Factory(t) { return new (t || RecordThreadStore)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(RecordThreadItemStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadStore, factory: RecordThreadStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadStore, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }, { type: RecordThreadItemStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadStoreFactory {
    constructor(recordListFactory, recordStoreFactory) {
        this.recordListFactory = recordListFactory;
        this.recordStoreFactory = recordStoreFactory;
    }
    create() {
        return new RecordThreadStore(this.recordListFactory, this.recordStoreFactory);
    }
    static { this.ɵfac = function RecordThreadStoreFactory_Factory(t) { return new (t || RecordThreadStoreFactory)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(RecordThreadItemStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadStoreFactory, factory: RecordThreadStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordListStoreFactory }, { type: RecordThreadItemStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NotificationsService {
    constructor(systemConfig, storeFactory, processService, messages, language, dynamicLabels) {
        this.systemConfig = systemConfig;
        this.storeFactory = storeFactory;
        this.processService = processService;
        this.messages = messages;
        this.language = language;
        this.dynamicLabels = dynamicLabels;
    }
    getOptions() {
        const ui = this.systemConfig.getConfigValue('ui');
        const options = ui?.notifications ?? null;
        return options;
    }
    initStore() {
        const options = this.getOptions();
        const config = {};
        this.setupListActions(config, options);
        this.setupItemConfig(config, options);
        const store = this.storeFactory.create();
        store.setItemMetadata(config.itemConfig.metadata);
        store.setListMetadata({ actions: config.listActions });
        const filters = {
            orderBy: options?.filters?.orderBy ?? 'date_entered',
            sortOrder: options?.filters?.sortOrder ?? 'asc',
            preset: { type: 'alerts' }
        };
        store.init(options.module, false, options?.pageSize ?? null);
        store.setFilters(filters).pipe(take(1)).subscribe();
        return store;
    }
    setupListActions(config, options) {
        config.listActions = options?.listActions ?? [];
        if ((options?.collapseListActions ?? null) !== null) {
            config.collapseListActions = options.collapseListActions;
        }
    }
    setupItemConfig(config, options) {
        config.itemConfig = {
            collapsible: options?.item?.collapsible ?? false,
            collapseLimit: options?.item?.collapseLimit ?? null,
            klass: options?.item?.itemClass ?? '',
            buttonClass: options?.item?.buttonClass ?? '',
            buttonGroupClass: options?.item?.buttonGroupClass ?? '',
            dynamicClass: options?.item?.dynamicClass ?? [],
            containerClass: options?.item?.containerClass ?? '',
            flexDirection: options?.item?.flexDirection ?? '',
            metadata: {},
        };
        this.setupItemMetadata(config.itemConfig.metadata, options.item.layout, options);
    }
    setupItemMetadata(metadata, layout, options) {
        if (layout && layout.header) {
            metadata.headerLayout = deepClone(layout.header);
        }
        if (layout && layout.body) {
            metadata.bodyLayout = deepClone(layout.body);
        }
        if (layout && layout.actions) {
            metadata.actions = deepClone(layout.actions);
        }
        if (options?.item && options?.item?.fields) {
            metadata.fields = deepClone(options.item.fields);
        }
        if ((options?.item?.collapseActions ?? null) !== null) {
            metadata.collapseActions = options?.item?.collapseActions;
        }
    }
    /**
     * Send notification mark-as-read request
     *
     * @param {object} store to use
     * @returns {object} Observable<Process>
     */
    markNotificationsAsRead(store) {
        const options = {
            action: 'record-thread-list-mark-as-read',
            module: store.module ?? 'alerts',
            ids: store.getRecordIds(),
        };
        return this.processService
            .submit('record-thread-list-mark-as-read', options)
            .pipe(tap((process) => {
            let handler = 'addSuccessMessageByKey';
            if (process.status === 'error') {
                handler = 'addDangerMessageByKey';
            }
            if (process.messages) {
                process.messages.forEach(message => {
                    this.messages[handler](message);
                });
            }
            store.getItemStores().forEach(notification => {
                const staging = notification?.recordStore?.getStaging() ?? {};
                const field = staging?.fields['is_read'] ?? null;
                if (field == null) {
                    return;
                }
                field.value = 'true';
            });
        }), catchError(err => {
            this.messages.addDangerMessageByKey('ERR_NOTIFICATIONS_MARK_AS_READ');
            throw err;
        }));
    }
    onLoadMore(notificationStore) {
        timer(1500).pipe(take(1)).subscribe(() => {
            notificationStore.markNotificationsAsRead();
        });
    }
    onRefresh(store, notificationStore) {
        const count = store.getRecordList().getMeta().unreadCount;
        let appStateCount = notificationStore.getNotificationsUnreadTotal();
        if (count > appStateCount) {
            let unreadCount = (count - appStateCount).toString();
            const labelTemplate = this.language.getFieldLabel('LBL_NEW_NOTIFICATION');
            const parsedLabel = this.dynamicLabels.parse(labelTemplate, { unread: unreadCount }, {});
            this.messages.addSuccessMessage(parsedLabel);
        }
        notificationStore.setNotificationsUnreadTotal(count);
    }
    static { this.ɵfac = function NotificationsService_Factory(t) { return new (t || NotificationsService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(RecordThreadStoreFactory), i0.ɵɵinject(ProcessService), i0.ɵɵinject(MessageService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(DynamicLabelService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NotificationsService, factory: NotificationsService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationsService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SystemConfigStore }, { type: RecordThreadStoreFactory }, { type: ProcessService }, { type: MessageService }, { type: LanguageStore }, { type: DynamicLabelService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$a = {
    notificationsEnabled: false,
    notificationsTotal: 0,
    notificationsUnreadTotal: 0
};
let internalState = deepClone(initialState$a);
let cache$ = null;
class NotificationStore {
    constructor(appStateStore, configs, notificationService) {
        this.appStateStore = appStateStore;
        this.configs = configs;
        this.notificationService = notificationService;
        this.store = new BehaviorSubject(internalState);
        this.state$ = this.store.asObservable();
        this.notificationPageSize = 0;
        this.notificationsUnreadTotal$ = this.state$.pipe(map(state => state.notificationsUnreadTotal), distinctUntilChanged());
        this.notificationsTotal$ = this.state$.pipe(map(state => state.notificationsTotal), distinctUntilChanged());
        this.notificationsEnabled$ = this.state$.pipe(map(state => state.notificationsEnabled), distinctUntilChanged());
    }
    /**
     * Clear state
     */
    clear() {
        cache$ = null;
        this.updateState(deepClone(initialState$a));
    }
    clearAuthBased() {
        this.clear();
        this.notificationStore.clear();
        this.notificationStore = null;
    }
    init() {
        if (this.appStateStore.isLoggedIn()) {
            this.initNotifications();
        }
    }
    /**
     * Initialize notifications
     */
    initNotifications() {
        if (this.notificationStore) {
            return;
        }
        this.notificationStore = this.notificationService.initStore();
    }
    /**
     * Enable notifications
     */
    enableNotifications() {
        this.initNotifications();
        this.updateState({ ...internalState, notificationsEnabled: true });
    }
    /**
     * Disable notifications
     */
    disableNotifications() {
        this.disableNotificationAutoRefresh();
        this.updateState({
            ...internalState,
            notificationsEnabled: false,
            notificationsTotal: 0,
            notificationsUnreadTotal: 0
        });
    }
    /**
     * Check if notifications are enabled
     */
    areNotificationsEnabled() {
        return internalState.notificationsEnabled;
    }
    /**
     * Call notification refresh
     */
    refreshNotifications() {
        if (!this.areNotificationsEnabled()) {
            return;
        }
        this.notificationStore.load(false).pipe(take(1)).subscribe(() => {
            this.notificationService.onRefresh(this.notificationStore, this);
        });
    }
    /**
     * Mark current notifications as read
     */
    markNotificationsAsRead() {
        if (!this.areNotificationsEnabled()) {
            return;
        }
        this.notificationStore.getRecordList().pagination$.pipe(take(1), tap(data => this.notificationPageSize = data.pageSize), tap(data => this.setNotificationsTotal(data.total))).subscribe();
        let unreadCountFromRecords = this.notificationStore.getRecordList().records.filter(item => item.attributes.is_read === false).length;
        let readCount = this.getNotificationsTotal() - this.getNotificationsUnreadTotal();
        timer(500).pipe(take(1))
            .subscribe(() => {
            if (this.getNotificationsUnreadTotal() > 0 && (this.notificationPageSize > readCount || unreadCountFromRecords > 0)) {
                this.notificationService.markNotificationsAsRead(this.notificationStore)
                    .subscribe((process) => {
                    const unreadCount = process?.data?.unreadCount ?? 0;
                    this.setNotificationsUnreadTotal(unreadCount);
                    this.setRecordAsReadTrue();
                });
            }
        });
    }
    /**
     * Run conditional navigation auto-refresh
     * @param view current view
     */
    conditionalNotificationRefresh(view = '') {
        if (!this.areNotificationsEnabled()) {
            return;
        }
        const reloadActions = this.configs.getUi('notifications_reload_actions') ?? null;
        const previousModule = this.getModule();
        if (!view) {
            view = this.getView();
        }
        if (!reloadActions || !previousModule) {
            return;
        }
        const actions = reloadActions[previousModule];
        if (!actions || !actions.length) {
            return;
        }
        const reload = actions.some(action => {
            return action === 'any' || action === view;
        });
        if (reload) {
            this.refreshNotifications();
        }
    }
    /**
     * Disable notifications auto-refresh
     */
    disableNotificationAutoRefresh() {
        this.notificationStore.disableAutoRefresh();
    }
    /**
     * Mark record as read
     */
    setRecordAsReadTrue() {
        this.notificationStore.getRecordList().records.forEach(record => {
            if (!record.attributes.is_read) {
                record.attributes.is_read = true;
            }
        });
    }
    /**
     * Set notification as unread
     * @param notificationsUnreadTotal
     */
    setNotificationsUnreadTotal(notificationsUnreadTotal) {
        this.updateState({ ...internalState, notificationsUnreadTotal });
    }
    /**
     * Set notification as total
     * @param notificationsTotal
     */
    setNotificationsTotal(notificationsTotal) {
        this.updateState({ ...internalState, notificationsTotal });
    }
    /**
     * Get notification total
     *
     * @returns number
     */
    getNotificationsTotal() {
        return internalState.notificationsTotal;
    }
    /**
     * Get unread notification count
     *
     * @returns number
     */
    getNotificationsUnreadTotal() {
        return internalState.notificationsUnreadTotal;
    }
    /**
     * Get Notification store
     *
     * @returns {object}
     */
    getNotificationStore() {
        return this.notificationStore;
    }
    /**
     * Get the current module
     *
     * @returns {string} current view
     */
    getModule() {
        return this.appStateStore.getModule();
    }
    /**
     * Get the current view
     *
     * @returns {string} current view
     */
    getView() {
        return this.appStateStore.getView();
    }
    /**
     * On login handlers
     * @protected
     */
    onLogin() {
    }
    /**
     * On logout handlers
     * @protected
     */
    onLogout() {
        this.disableNotifications();
        this.clearAuthBased();
    }
    /**
     * Check if loaded
     */
    isCached() {
        return cache$ !== null;
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(internalState = state);
    }
    /**
     * Set pre-loaded adminMetadata and cache
     */
    set(state) {
        cache$ = of(state).pipe(shareReplay(1));
        this.updateState(state);
    }
    static { this.ɵfac = function NotificationStore_Factory(t) { return new (t || NotificationStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(NotificationsService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NotificationStore, factory: NotificationStore.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationStore, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AppStateStore }, { type: SystemConfigStore }, { type: NotificationsService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AuthService {
    constructor(http, router, message, stateManager, languageStore, appStateStore, localStorage, configs, baseRoute, notificationStore) {
        this.http = http;
        this.router = router;
        this.message = message;
        this.stateManager = stateManager;
        this.languageStore = languageStore;
        this.appStateStore = appStateStore;
        this.localStorage = localStorage;
        this.configs = configs;
        this.baseRoute = baseRoute;
        this.notificationStore = notificationStore;
        this.isUserLoggedIn = new BehaviorSubject(false);
        this.currentUserSubject = new BehaviorSubject({});
        this.currentUser$ = this.currentUserSubject.asObservable().pipe(distinctUntilChanged());
    }
    isLoggedIn() {
        return this.isUserLoggedIn.value;
    }
    getCurrentUser() {
        return this.currentUserSubject.value;
    }
    setCurrentUser(data) {
        this.appStateStore.setCurrentUser(data);
        this.currentUserSubject.next(data);
        this.isUserLoggedIn.next(true);
    }
    doLogin(username, password, onSuccess, onError) {
        let loginUrl = 'login';
        loginUrl = this.baseRoute.appendNativeAuth(loginUrl);
        loginUrl = this.baseRoute.calculateRoute(loginUrl);
        const headers = new HttpHeaders({
            'Content-Type': 'application/json',
        });
        return this.http.post(loginUrl, {
            username,
            password
        }, { headers }).subscribe((response) => {
            if (this.baseRoute.isNativeAuth()) {
                window.location.href = this.baseRoute.removeNativeAuth();
            }
            this.appStateStore.updateInitialAppLoading(true);
            onSuccess(response);
            this.isUserLoggedIn.next(true);
            this.setCurrentUser(response);
            this.notificationStore.enableNotifications();
            this.notificationStore.refreshNotifications();
        }, (error) => {
            onError(error);
        });
    }
    /**
     * Logout user
     *
     * @param {string} messageKey of message to display
     * @param {boolean} redirect to home
     */
    logout(messageKey = 'LBL_LOGOUT_SUCCESS', redirect = true) {
        this.appStateStore.updateLoading('logout', true, false);
        const logoutConfig = this.configs.getConfigValue('logout') ?? [];
        let logoutUrl = (logoutConfig?.path ?? 'logout');
        let redirectLogout = isTrue(logoutConfig?.redirect ?? false);
        const afterLogoutPath = (logoutConfig?.after_logout_path ?? './');
        if (this.baseRoute.isNativeAuth()) {
            logoutUrl = this.baseRoute.getNativeOutLogoutUrl();
            redirectLogout = false;
        }
        logoutUrl = this.baseRoute.calculateRoute(logoutUrl);
        const body = new HttpParams();
        const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
        if (this.appStateStore.getActiveRequests() < 1) {
            this.callLogout(logoutUrl, body, headers, redirect, messageKey, redirectLogout, afterLogoutPath);
        }
        else {
            this.appStateStore.activeRequests$.pipe(filter(value => value < 1), take(1)).subscribe(() => {
                this.callLogout(logoutUrl, body, headers, redirect, messageKey, redirectLogout, afterLogoutPath);
            });
        }
    }
    /**
     * Call logout
     * @param logoutUrl
     * @param body
     * @param headers
     * @param redirect
     * @param messageKey
     * @param redirectLogout
     * @protected
     */
    callLogout(logoutUrl, body, headers, redirect, messageKey, redirectLogout, afterLogoutPath) {
        this.resetState();
        if (redirectLogout) {
            window.location.href = logoutUrl;
            return;
        }
        this.http.post(logoutUrl, body.toString(), { headers, responseType: 'text' })
            .pipe(take(1), catchError(err => {
            this.message.log('Logout failed');
            return throwError(err);
        }), finalize(() => {
            this.appStateStore.updateInitialAppLoading(true);
            this.appStateStore.updateLoading('logout', false, false);
            this.appStateStore.setCurrentUser(null);
            this.stateManager.clearAuthBased();
            this.configs.clear();
            if (redirect === true) {
                window.location.href = afterLogoutPath;
            }
        }))
            .subscribe(() => {
            this.message.log('Logout success');
            if (!isEmptyString(messageKey)) {
                this.message.addSuccessMessageByKey(messageKey);
            }
        }, () => {
            this.message.log('Error on logout');
            if (!isEmptyString(messageKey)) {
                this.message.addSuccessMessageByKey(messageKey);
            }
        });
    }
    /**
     * On logout state reset
     */
    resetState() {
        this.stateManager.clearAuthBased();
        this.localStorage.clear();
        this.isUserLoggedIn.next(false);
    }
    /**
     * Fetch session status from backend
     *
     * @returns {{}} Observable<SessionStatus>
     */
    fetchSessionStatus() {
        let url = 'session-status';
        url = this.baseRoute.appendNativeAuth(url);
        url = this.baseRoute.calculateRoute(url);
        const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
        return this.http.get(url, { headers });
    }
    /**
     * Get route for session expired handling
     * @return string
     */
    getSessionExpiredRoute() {
        const sessionExpiredConfig = this.configs.getConfigValue('session-expired') ?? [];
        return (sessionExpiredConfig?.path ?? 'Login');
    }
    /**
     * Handle invalid session on request
     * @return boolean
     */
    handleInvalidSession(message) {
        const redirect = this.sessionExpiredRedirect();
        if (redirect) {
            this.handleSessionExpiredRedirect();
            return;
        }
        this.logout(message);
    }
    /**
     * Redirect to route configured for session expiry
     */
    handleSessionExpiredRedirect() {
        window.location.href = this.getSessionExpiredRoute();
    }
    /**
     * Is to re-direct on session expiry
     * @return boolean
     */
    sessionExpiredRedirect() {
        const sessionExpiredConfig = this.configs.getConfigValue('session-expired') ?? [];
        return isTrue(sessionExpiredConfig?.redirect ?? false);
    }
    static { this.ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1$3.HttpClient), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(MessageService), i0.ɵɵinject(StateManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(BaseRouteService), i0.ɵɵinject(NotificationStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$3.HttpClient }, { type: i1$2.Router }, { type: MessageService }, { type: StateManager }, { type: LanguageStore }, { type: AppStateStore }, { type: LocalStorageService }, { type: SystemConfigStore }, { type: BaseRouteService }, { type: NotificationStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FooterUiComponent_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 8)(2, "a", 9);
    i0.ɵɵlistener("click", function FooterUiComponent_ng_container_6_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r6); const ctx_r5 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r5.backToTop()); });
    i0.ɵɵelementStart(3, "span");
    i0.ɵɵtext(4, " Back To Top ");
    i0.ɵɵelement(5, "scrm-image", 10);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementContainerEnd();
} }
function FooterUiComponent_ng_template_8_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 11)(1, "div", 12)(2, "h5", 13);
    i0.ɵɵtext(3, "\u00A9 Powered By SugarCRM");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "button", 14);
    i0.ɵɵlistener("click", function FooterUiComponent_ng_template_8_Template_button_click_4_listener() { const restoredCtx = i0.ɵɵrestoreView(_r9); const modal_r7 = restoredCtx.$implicit; return i0.ɵɵresetView(modal_r7.dismiss("Cross click")); });
    i0.ɵɵelement(5, "scrm-image", 15);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 16)(7, "p");
    i0.ɵɵtext(8, " \u00A9 2004-2013 SugarCRM Inc. The Program is provided AS IS, without warranty. Licensed under AGPLv3. ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "p");
    i0.ɵɵtext(10, " This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation, including the additional permission set forth in the source code header. ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "p");
    i0.ɵɵtext(12, " SugarCRM is a trademark of SugarCRM, Inc. All other company and product names may be trademarks of the respective companies with which they are associated. ");
    i0.ɵɵelementEnd()()();
} }
function FooterUiComponent_ng_template_10_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 17)(1, "div", 12)(2, "h5", 13);
    i0.ɵɵtext(3, "\u00A9 Supercharged by SuiteCRM");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "button", 14);
    i0.ɵɵlistener("click", function FooterUiComponent_ng_template_10_Template_button_click_4_listener() { const restoredCtx = i0.ɵɵrestoreView(_r12); const modal_r10 = restoredCtx.$implicit; return i0.ɵɵresetView(modal_r10.dismiss("Cross click")); });
    i0.ɵɵelement(5, "scrm-image", 15);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 16)(7, "p");
    i0.ɵɵtext(8, " SuiteCRM has been written and assembled by SalesAgility. The Program is provided AS IS, without warranty. Licensed under AGPLv3. ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "p");
    i0.ɵɵtext(10, " This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation, including the additional permission set forth in the source code header. ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "p");
    i0.ɵɵtext(12, " SuiteCRM is a trademark of SalesAgility Ltd. All other company and product names may be trademarks of the respective companies with which they are associated. ");
    i0.ɵɵelementEnd()()();
} }
class FooterUiComponent {
    constructor(modalService, authService) {
        this.modalService = modalService;
        this.authService = authService;
    }
    openSugarCopyright(sugarcopyright) {
        this.modalService.open(sugarcopyright, {
            ariaLabelledBy: 'modal-basic-title',
            centered: true,
            size: 'lg'
        }).result.then((result) => {
            this.closeResult = `Closed with: ${result}`;
        }, (reason) => {
            this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
        });
    }
    openSuiteCopyright(suitecopyright) {
        this.modalService.open(suitecopyright, {
            ariaLabelledBy: 'modal-basic-title',
            centered: true,
            size: 'lg'
        }).result.then((result) => {
            this.closeResult = `Closed with: ${result}`;
        }, (reason) => {
            this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
        });
    }
    getDismissReason(reason) {
        if (reason === ModalDismissReasons.ESC) {
            return 'by pressing ESC';
        }
        else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
            return 'by clicking on a backdrop';
        }
        else {
            return `with: ${reason}`;
        }
    }
    backToTop() {
        document.body.scrollTop = 0; // For Safari
        document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
    }
    ngOnInit() {
        this.authSub = this.authService.isUserLoggedIn.subscribe(value => {
            this.isUserLoggedIn = value;
        });
    }
    ngOnDestroy() {
        this.authSub.unsubscribe();
    }
    static { this.ɵfac = function FooterUiComponent_Factory(t) { return new (t || FooterUiComponent)(i0.ɵɵdirectiveInject(i3$1.NgbModal), i0.ɵɵdirectiveInject(AuthService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FooterUiComponent, selectors: [["scrm-footer-ui"]], decls: 12, vars: 1, consts: [[1, "footer"], [1, "copyright-links"], ["data-toggle", "modal", "data-target", ".copyright-suitecrm", 1, "footer-link", 3, "click"], ["data-toggle", "modal", "data-target", ".copyright-sugarcrm", 1, "footer-link", 3, "click"], [4, "ngIf"], [1, "copyright"], ["sugarcopyright", ""], ["suitecopyright", ""], [1, "back-to-top"], [1, "footer-link", 3, "click"], ["image", "arrow_up_filled", 1, "sicon", "back-top-icon"], ["role", "dialog", "aria-hidden", "true", 1, "copyright-sugarcrm"], [1, "modal-header"], [1, "modal-title"], ["type", "button", "data-dismiss", "modal", "aria-label", "Close", 1, "close", 3, "click"], ["image", "icon_modal_close", 1, "sicon"], [1, "modal-body"], ["role", "dialog", "aria-hidden", "true", 1, "copyright-suitecrm"]], template: function FooterUiComponent_Template(rf, ctx) { if (rf & 1) {
            const _r13 = i0.ɵɵgetCurrentView();
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "a", 2);
            i0.ɵɵlistener("click", function FooterUiComponent_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r13); const _r3 = i0.ɵɵreference(11); return i0.ɵɵresetView(ctx.openSuiteCopyright(_r3)); });
            i0.ɵɵtext(3, " \u00A9 Supercharged by SuiteCRM ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(4, "a", 3);
            i0.ɵɵlistener("click", function FooterUiComponent_Template_a_click_4_listener() { i0.ɵɵrestoreView(_r13); const _r1 = i0.ɵɵreference(9); return i0.ɵɵresetView(ctx.openSugarCopyright(_r1)); });
            i0.ɵɵtext(5, " \u00A9 Powered By SugarCRM ");
            i0.ɵɵelementEnd()();
            i0.ɵɵtemplate(6, FooterUiComponent_ng_container_6_Template, 6, 0, "ng-container", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(7, "div", 5);
            i0.ɵɵtemplate(8, FooterUiComponent_ng_template_8_Template, 13, 0, "ng-template", null, 6, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵtemplate(10, FooterUiComponent_ng_template_10_Template, 13, 0, "ng-template", null, 7, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("ngIf", ctx.isUserLoggedIn);
        } }, dependencies: [i2.NgIf, ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FooterUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-footer-ui', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start of footer section -->\n<div class=\"footer\">\n  <div class=\"copyright-links\">\n    <a (click)=\"openSuiteCopyright(suitecopyright)\" class=\"footer-link\" data-toggle=\"modal\"\n       data-target=\".copyright-suitecrm\">\n      &copy; Supercharged by SuiteCRM\n    </a>\n    <a (click)=\"openSugarCopyright(sugarcopyright)\" class=\"footer-link\" data-toggle=\"modal\"\n       data-target=\".copyright-sugarcrm\">\n      &copy; Powered By SugarCRM\n    </a>\n  </div>\n  <ng-container *ngIf=\"this.isUserLoggedIn\">\n    <div class=\"back-to-top\">\n      <a (click)=\"backToTop()\" class=\"footer-link\">\n        <span>\n          Back To Top\n          <scrm-image class=\"sicon back-top-icon\" image=\"arrow_up_filled\"></scrm-image>\n        </span>\n      </a>\n    </div>\n  </ng-container>\n</div>\n<!-- End of footer section -->\n\n<!-- Start of copyright modal section -->\n\n<div class=\"copyright\">\n\n    <!-- Start of SugarCRM Copyright notice modal -->\n\n    <ng-template #sugarcopyright let-modal>\n\n        <div class=\"copyright-sugarcrm\" role=\"dialog\" aria-hidden=\"true\">\n            <div class=\"modal-header\">\n                <h5 class=\"modal-title\">&copy; Powered By SugarCRM</h5>\n                <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"\n                        (click)=\"modal.dismiss('Cross click')\">\n                    <scrm-image class=\"sicon\" image=\"icon_modal_close\"></scrm-image>\n                </button>\n            </div>\n            <div class=\"modal-body\">\n                <p>\n                    &copy; 2004-2013 SugarCRM Inc. The Program is provided AS IS, without\n                    warranty. Licensed under AGPLv3.\n                </p>\n                <p>\n                    This program is free software; you can redistribute it and/or modify\n                    it under the terms of the GNU Affero General Public License version\n                    3 as published by the Free Software Foundation, including the\n                    additional permission set forth in the source code header.\n                </p>\n                <p>\n                    SugarCRM is a trademark of SugarCRM, Inc. All other company and\n                    product names may be trademarks of the respective companies with\n                    which they are associated.\n                </p>\n            </div>\n        </div>\n\n    </ng-template>\n\n    <!-- End of SugarCRM Copyright notice modal -->\n\n    <!-- Start of SuiteCRM Copyright notice modal -->\n\n    <ng-template #suitecopyright let-modal>\n\n        <div class=\"copyright-suitecrm\" role=\"dialog\" aria-hidden=\"true\">\n            <div class=\"modal-header\">\n                <h5 class=\"modal-title\">&copy; Supercharged by SuiteCRM</h5>\n                <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"\n                        (click)=\"modal.dismiss('Cross click')\">\n                    <scrm-image class=\"sicon\" image=\"icon_modal_close\"></scrm-image>\n                </button>\n            </div>\n            <div class=\"modal-body\">\n                <p>\n                    SuiteCRM has been written and assembled by SalesAgility. The Program\n                    is provided AS IS, without warranty. Licensed under AGPLv3.\n                </p>\n                <p>\n                    This program is free software; you can redistribute it and/or modify\n                    it under the terms of the GNU Affero General Public License version\n                    3 as published by the Free Software Foundation, including the\n                    additional permission set forth in the source code header.\n                </p>\n                <p>\n                    SuiteCRM is a trademark of SalesAgility Ltd. All other company and\n                    product names may be trademarks of the respective companies with\n                    which they are associated.\n                </p>\n            </div>\n        </div>\n\n    </ng-template>\n\n    <!-- End of SuiteCRM Copyright notice modal -->\n</div>\n\n<!-- End of copyright modal section -->\n" }]
    }], function () { return [{ type: i3$1.NgbModal }, { type: AuthService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FooterUiModule {
    static { this.ɵfac = function FooterUiModule_Factory(t) { return new (t || FooterUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FooterUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FooterUiModule, [{
        type: NgModule,
        args: [{
                declarations: [FooterUiComponent],
                exports: [FooterUiComponent],
                imports: [
                    CommonModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FooterUiModule, { declarations: [FooterUiComponent], imports: [CommonModule,
        ImageModule], exports: [FooterUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FullPageSpinnerComponent {
    constructor() {
    }
    ngOnInit() {
    }
    static { this.ɵfac = function FullPageSpinnerComponent_Factory(t) { return new (t || FullPageSpinnerComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FullPageSpinnerComponent, selectors: [["app-full-page-spinner"]], decls: 20, vars: 0, consts: [[1, "app-overlay"], ["id", "overlay-spinner"], [1, "app-loading"], [1, "sk-cube-grid"], [1, "sk-cube", "sk-cube1", "sk-cube-primary"], [1, "sk-cube", "sk-cube2", "sk-cube-secondary"], [1, "sk-cube", "sk-cube3", "sk-cube-secondary"], [1, "sk-cube", "sk-cube4", "sk-cube-primary"], [1, "sk-cube", "sk-cube5", "sk-cube-secondary"], [1, "sk-cube", "sk-cube6", "sk-cube-secondary"], [1, "sk-cube", "sk-cube7", "sk-cube-primary"], [1, "sk-cube", "sk-cube8", "sk-cube-primary"], [1, "sk-cube", "sk-cube9", "sk-cube-primary"]], template: function FullPageSpinnerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2)(3, "div", 3);
            i0.ɵɵelement(4, "div", 4)(5, "div", 4)(6, "div", 5)(7, "div", 6)(8, "div", 7)(9, "div", 7)(10, "div", 8)(11, "div", 9)(12, "div", 10)(13, "div", 10)(14, "div", 11)(15, "div", 12)(16, "div", 10)(17, "div", 10)(18, "div", 11)(19, "div", 12);
            i0.ɵɵelementEnd()()()();
        } }, styles: [".app-overlay[_ngcontent-%COMP%]{position:fixed;display:flex;justify-content:center;align-items:center;flex-direction:column;width:100%;height:100%;inset:0;background-color:#fff9;z-index:4000;cursor:default}.app-loading[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%}.app-loading[_ngcontent-%COMP%]   .spinner[_ngcontent-%COMP%]{height:200px;width:200px;animation:scaleIn 4s linear infinite;transform-origin:center center;position:absolute;inset:0;margin:auto}.app-loading[_ngcontent-%COMP%]   .spinner[_ngcontent-%COMP%]   .path[_ngcontent-%COMP%]{stroke-dasharray:1,200;stroke-dashoffset:0;animation:dash 1.5s ease-in-out infinite;stroke-linecap:round;stroke:#ddd}.sk-cube-primary[_ngcontent-%COMP%]{background-color:#e67062}.sk-cube-secondary[_ngcontent-%COMP%]{background-color:#4e5063}.sk-cube-grid[_ngcontent-%COMP%]{width:100px;height:100px}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube[_ngcontent-%COMP%]{width:25%;height:25%;float:left;animation:_ngcontent-%COMP%_sk-cubeGridScaleDelay 1.3s infinite ease-in-out}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube1[_ngcontent-%COMP%]{animation-delay:.2s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube2[_ngcontent-%COMP%]{animation-delay:.3s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube3[_ngcontent-%COMP%]{animation-delay:.4s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube4[_ngcontent-%COMP%]{animation-delay:.1s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube5[_ngcontent-%COMP%]{animation-delay:.2s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube6[_ngcontent-%COMP%]{animation-delay:.3s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube7[_ngcontent-%COMP%]{animation-delay:0s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube8[_ngcontent-%COMP%]{animation-delay:.1s}.sk-cube-grid[_ngcontent-%COMP%]   .sk-cube9[_ngcontent-%COMP%]{animation-delay:.2s}@keyframes _ngcontent-%COMP%_sk-cubeGridScaleDelay{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}"] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FullPageSpinnerComponent, [{
        type: Component,
        args: [{ selector: 'app-full-page-spinner', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"app-overlay\">\n    <div id=\"overlay-spinner\">\n        <div class=\"app-loading\">\n            <div class=\"sk-cube-grid\">\n                <div class=\"sk-cube sk-cube1 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube1 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube2 sk-cube-secondary\"></div>\n                <div class=\"sk-cube sk-cube3 sk-cube-secondary\"></div>\n                <div class=\"sk-cube sk-cube4 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube4 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube5 sk-cube-secondary\"></div>\n                <div class=\"sk-cube sk-cube6 sk-cube-secondary\"></div>\n                <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube8 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube9 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube7 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube8 sk-cube-primary\"></div>\n                <div class=\"sk-cube sk-cube9 sk-cube-primary\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n", styles: [".app-overlay{position:fixed;display:flex;justify-content:center;align-items:center;flex-direction:column;width:100%;height:100%;inset:0;background-color:#fff9;z-index:4000;cursor:default}.app-loading{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%}.app-loading .spinner{height:200px;width:200px;animation:scaleIn 4s linear infinite;transform-origin:center center;position:absolute;inset:0;margin:auto}.app-loading .spinner .path{stroke-dasharray:1,200;stroke-dashoffset:0;animation:dash 1.5s ease-in-out infinite;stroke-linecap:round;stroke:#ddd}.sk-cube-primary{background-color:#e67062}.sk-cube-secondary{background-color:#4e5063}.sk-cube-grid{width:100px;height:100px}.sk-cube-grid .sk-cube{width:25%;height:25%;float:left;animation:sk-cubeGridScaleDelay 1.3s infinite ease-in-out}.sk-cube-grid .sk-cube1{animation-delay:.2s}.sk-cube-grid .sk-cube2{animation-delay:.3s}.sk-cube-grid .sk-cube3{animation-delay:.4s}.sk-cube-grid .sk-cube4{animation-delay:.1s}.sk-cube-grid .sk-cube5{animation-delay:.2s}.sk-cube-grid .sk-cube6{animation-delay:.3s}.sk-cube-grid .sk-cube7{animation-delay:0s}.sk-cube-grid .sk-cube8{animation-delay:.1s}.sk-cube-grid .sk-cube9{animation-delay:.2s}@keyframes sk-cubeGridScaleDelay{0%,70%,to{transform:scaleZ(1)}35%{transform:scale3D(0,0,1)}}\n"] }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FullPageSpinnerModule {
    static { this.ɵfac = function FullPageSpinnerModule_Factory(t) { return new (t || FullPageSpinnerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FullPageSpinnerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AngularSvgIconModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FullPageSpinnerModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    FullPageSpinnerComponent
                ],
                exports: [
                    FullPageSpinnerComponent
                ],
                imports: [
                    CommonModule,
                    AngularSvgIconModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FullPageSpinnerModule, { declarations: [FullPageSpinnerComponent], imports: [CommonModule,
        AngularSvgIconModule], exports: [FullPageSpinnerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsFetchGQL {
    constructor(apollo) {
        this.apollo = apollo;
    }
    /**
     * Fetch statistics data from backend
     *
     * @param {string} module name
     * @param {object} queries to use
     * @returns {object} Observable<ApolloQueryResult<any>>
     */
    fetch(module, queries) {
        const queryOptions = {
            query: gql `
            query batchedStatistics($module: String!, $queries: Iterable!){
              batchedStatistics(module: $module, queries: $queries) {
                  _id
                  id
                  items
              }
            }
        `,
            variables: {
                module,
                queries,
            },
        };
        return this.apollo.query(queryOptions).pipe(map((result) => {
            const statistics = {};
            const response = (result.data && result.data.batchedStatistics) || {};
            const items = response.items || {};
            const itemKeys = Object.keys(items);
            if (itemKeys && itemKeys.length) {
                itemKeys.forEach((itemKey) => {
                    const item = items[itemKey];
                    // eslint-disable-next-line no-underscore-dangle
                    const key = itemKey || item._id;
                    statistics[key] = {
                        // eslint-disable-next-line no-underscore-dangle
                        id: item._id,
                        data: item.data,
                        metadata: item.metadata
                    };
                });
            }
            return statistics;
        }));
    }
    static { this.ɵfac = function StatisticsFetchGQL_Factory(t) { return new (t || StatisticsFetchGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StatisticsFetchGQL, factory: StatisticsFetchGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsFetchGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$9 = {
    module: '',
    query: {},
    statistic: {
        id: '',
        data: {}
    },
    loading: false
};
class StatisticsStore {
    constructor(fetchGQL) {
        this.fetchGQL = fetchGQL;
        this.cache$ = null;
        this.internalState = deepClone(initialState$9);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.statistic$ = this.state$.pipe(map(state => state.statistic), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading), distinctUntilChanged());
    }
    clear() {
        this.store.unsubscribe();
        this.cache$ = null;
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get Statistic query
     *
     * @returns {object} StatisticsQuery
     */
    getQuery() {
        return deepClone(this.internalState.query);
    }
    get context() {
        return this.internalState.query.context;
    }
    set context(context) {
        const query = deepClone(this.internalState.query);
        query.context = context;
        this.updateState({
            ...this.internalState,
            query
        });
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {object} query to use
     * @param {boolean} load if to load
     * @returns {object} Observable<any>
     */
    init(module, query, load = true) {
        this.internalState.module = module;
        this.updateState({
            ...this.internalState,
            module,
            query
        });
        if (load === false) {
            return null;
        }
        return this.load();
    }
    /**
     * Load / reload statistics
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<ListViewState>
     */
    load(useCache = true) {
        this.updateState({
            ...this.internalState,
            loading: true,
        });
        return this.fetchStatistics(this.internalState.module, this.getQuery(), useCache).pipe(map((data) => this.mapStatistics(data)), tap((statistic) => {
            this.addNewState(statistic);
        }));
    }
    /**
     * Set loading
     *
     * @param {boolean} loading bool
     */
    setLoading(loading) {
        this.updateState({
            ...this.internalState,
            loading
        });
    }
    /**
     * Set Statistic value
     *
     * @param {string} key string
     * @param {object} statistic Statistic
     * @param {boolean} cache bool
     */
    setStatistic(key, statistic, cache = false) {
        this.addNewState(statistic);
        if (!cache) {
            return;
        }
        const statMap = {};
        statMap[key] = statistic;
        this.cache$ = of(statMap).pipe(shareReplay(1));
    }
    addNewState(statistic) {
        this.updateState({
            ...this.internalState,
            statistic,
            loading: false
        });
    }
    mapStatistics(data) {
        const keys = Object.keys(data);
        const key = keys && keys.length && keys[0];
        let statistic = { id: '', data: {} };
        if (key) {
            statistic = data[key];
        }
        return statistic;
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Get records cached Observable or call the backend
     *
     * @param {string} module to use
     * @param {object} query to use
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<any>
     */
    fetchStatistics(module, query, useCache = true) {
        const queries = {};
        queries[query.key] = query;
        if (this.cache$ == null || useCache === false) {
            this.cache$ = this.fetchGQL.fetch(module, queries).pipe(shareReplay(1));
        }
        return this.cache$;
    }
    static { this.ɵfac = function StatisticsStore_Factory(t) { return new (t || StatisticsStore)(i0.ɵɵinject(StatisticsFetchGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StatisticsStore, factory: StatisticsStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsStore, [{
        type: Injectable
    }], function () { return [{ type: StatisticsFetchGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$8 = {
    module: '',
    query: {},
    statistic: {
        id: '',
        data: {}
    },
    loading: false
};
class SingleValueStatisticsStore extends StatisticsStore {
    constructor(fetchGQL, fieldManager) {
        super(fetchGQL);
        this.fetchGQL = fetchGQL;
        this.fieldManager = fieldManager;
        this.cache$ = null;
        this.internalState = deepClone(initialState$8);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.statistic$ = this.state$.pipe(map(state => state.statistic), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading), distinctUntilChanged());
    }
    addNewState(statistic) {
        if (!statistic.metadata || !statistic.metadata.dataType) {
            return;
        }
        const field = this.fieldManager.buildShallowField(statistic.metadata.dataType, statistic.data.value);
        field.metadata = {
            digits: 0
        };
        this.updateState({
            ...this.internalState,
            statistic,
            field,
            loading: false
        });
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        super.updateState(state);
    }
    static { this.ɵfac = function SingleValueStatisticsStore_Factory(t) { return new (t || SingleValueStatisticsStore)(i0.ɵɵinject(StatisticsFetchGQL), i0.ɵɵinject(FieldManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SingleValueStatisticsStore, factory: SingleValueStatisticsStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SingleValueStatisticsStore, [{
        type: Injectable
    }], function () { return [{ type: StatisticsFetchGQL }, { type: FieldManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SingleValueStatisticsStoreFactory {
    constructor(fetchGQL, fieldManager) {
        this.fetchGQL = fetchGQL;
        this.fieldManager = fieldManager;
    }
    create() {
        return new SingleValueStatisticsStore(this.fetchGQL, this.fieldManager);
    }
    static { this.ɵfac = function SingleValueStatisticsStoreFactory_Factory(t) { return new (t || SingleValueStatisticsStoreFactory)(i0.ɵɵinject(StatisticsFetchGQL), i0.ɵɵinject(FieldManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SingleValueStatisticsStoreFactory, factory: SingleValueStatisticsStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SingleValueStatisticsStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: StatisticsFetchGQL }, { type: FieldManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function GridWidgetComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelement(1, "scrm-label", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r0.messageLabelKey);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 8);
    i0.ɵɵelement(2, "scrm-image", 9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r6 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("image", col_r6.icon)("klass", col_r6.iconClass);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵelement(1, "scrm-field", 13);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const statistics_r15 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("type", statistics_r15.field.type)("field", statistics_r15.field);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 14);
    i0.ɵɵelement(1, "scrm-inline-loading-spinner");
    i0.ɵɵelementEnd();
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_div_1_Template, 2, 2, "div", 10);
    i0.ɵɵtemplate(2, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_div_2_Template, 2, 0, "div", 11);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const statistics_r15 = ctx.ngIf;
    const ctx_r9 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", statistics_r15.field);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", statistics_r15.loading && ctx_r9.loading);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 15);
    i0.ɵɵelement(2, "scrm-label", 16);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r6 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r10 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", col_r6.labelKey)("module", ctx_r10.getContextModule());
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 17)(2, "label");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r2 = i0.ɵɵnextContext(4).ngIf;
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(vm_r2.description);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 19);
    i0.ɵɵelement(1, "scrm-dynamic-label", 20);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r6 = i0.ɵɵnextContext(3).$implicit;
    const vm_r2 = i0.ɵɵnextContext(2).ngIf;
    const ctx_r21 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("context", ctx_r21.getMessageContext())("fields", ctx_r21.getMessageFields(vm_r2.statistics))("labelKey", col_r6.dynamicLabel);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 14);
    i0.ɵɵelement(1, "scrm-inline-loading-spinner");
    i0.ɵɵelementEnd();
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_div_1_Template, 2, 3, "div", 18);
    i0.ɵɵtemplate(2, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_div_2_Template, 2, 0, "div", 11);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r12 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r12.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r12.loading);
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵtext(2, " - ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r6 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r13 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("widget-entry-value ", ctx_r13.getSizeClass(col_r6.size), "");
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_1_Template, 3, 2, "ng-container", 7);
    i0.ɵɵtemplate(2, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_2_Template, 3, 2, "ng-container", 7);
    i0.ɵɵtemplate(3, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_3_Template, 3, 2, "ng-container", 7);
    i0.ɵɵtemplate(4, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_4_Template, 4, 1, "ng-container", 7);
    i0.ɵɵtemplate(5, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_5_Template, 3, 2, "ng-container", 7);
    i0.ɵɵtemplate(6, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_ng_container_6_Template, 3, 3, "ng-container", 7);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r6 = i0.ɵɵnextContext().$implicit;
    const vm_r2 = i0.ɵɵnextContext(2).ngIf;
    const ctx_r7 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.statistic && vm_r2.statistics[col_r6.statistic]);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.labelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.descriptionKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.dynamicLabel);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.statistic && !ctx_r7.loading && (!vm_r2.statistics[col_r6.statistic].field || vm_r2.statistics[col_r6.statistic].field && ctx_r7.isEmptyFieldValue(vm_r2.statistics[col_r6.statistic].field.value)));
} }
function GridWidgetComponent_div_1_ng_container_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, GridWidgetComponent_div_1_ng_container_1_div_2_ng_container_1_Template, 7, 6, "ng-container", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r6 = ctx.$implicit;
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵclassMapInterpolate2("", ctx_r5.getColClass(), " ", ctx_r5.getClass(col_r6), "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r6.display !== "hidden");
} }
function GridWidgetComponent_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵtemplate(2, GridWidgetComponent_div_1_ng_container_1_div_2_Template, 2, 5, "div", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r4 = ctx.$implicit;
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate4("d-flex ", ctx_r3.getJustify(item_r4.justify), " ", ctx_r3.getAlign(item_r4.align), " ", ctx_r3.getRowClass(), " ", ctx_r3.getLayoutRowClass(item_r4), "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", item_r4.cols);
} }
function GridWidgetComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵtemplate(1, GridWidgetComponent_div_1_ng_container_1_Template, 3, 7, "ng-container", 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r2 = ctx.ngIf;
    i0.ɵɵpropertyInterpolate("ngbTooltip", vm_r2.tooltipTitleText);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", vm_r2.layout);
} }
class GridWidgetComponent {
    constructor(language, factory) {
        this.language = language;
        this.factory = factory;
        this.loading = true;
        this.subs = [];
        this.statistics = {};
    }
    ngOnInit() {
        const isValid = this.validateConfig();
        if (!isValid) {
            return;
        }
        this.gridWidgetInput = this.config;
        this.buildStatistics();
        this.setupLoading$();
        this.setupVM();
        this.setupReload();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    validateConfig() {
        if (!this.config || !this.config.layout) {
            this.messageLabelKey = 'LBL_CONFIG_NO_CONFIG';
            return false;
        }
        if (!this.config.queryArgs.context || !this.config.queryArgs.module) {
            this.messageLabelKey = 'LBL_CONFIG_BAD_CONTEXT';
            return false;
        }
        if (!this.config.widgetConfig) {
            this.messageLabelKey = 'LBL_CONFIG_NO_CONFIG';
            return false;
        }
        if (!this.config.layout || !this.config.layout.rows) {
            this.messageLabelKey = 'LBL_CONFIG_NO_STATISTICS_KEY';
            return false;
        }
        return true;
    }
    getRowClass() {
        return this.gridWidgetInput.rowClass;
    }
    getColClass() {
        return this.gridWidgetInput.columnClass;
    }
    getContextModule() {
        return this.gridWidgetInput.queryArgs.context.module;
    }
    getMessageContext() {
        const module = this.getContextModule();
        if (!module) {
            return {};
        }
        return {
            module
        };
    }
    getMessageFields(statistics) {
        if (!statistics || !Object.keys(statistics).length) {
            return {};
        }
        const fields = {};
        Object.keys(statistics).forEach(key => {
            const statistic = statistics[key];
            fields[key] = statistic.field;
        });
        return fields;
    }
    getSizeClass(size) {
        const sizeMap = {
            regular: 'text-regular',
            medium: 'text-medium',
            large: 'text-large',
            'x-large': 'text-x-large',
            'xx-large': 'text-xx-large',
            huge: 'text-huge'
        };
        return sizeMap[size] || 'text-regular';
    }
    getFontWeight(bold) {
        let fontWeight = 'font-weight-normal';
        if (bold && isTrue(bold)) {
            fontWeight = 'font-weight-bolder';
        }
        return fontWeight;
    }
    getColor(color) {
        const sizeMap = {
            yellow: 'text-yellow',
            blue: 'text-blue',
            green: 'text-green',
            red: 'text-red',
            purple: 'text-purple',
            dark: 'text-dark',
            grey: 'text-grey'
        };
        return sizeMap[color] || '';
    }
    getJustify(justify) {
        const justifyMap = {
            start: 'justify-content-start',
            end: 'justify-content-end',
            center: 'justify-content-center',
            between: 'justify-content-between',
            around: 'justify-content-around'
        };
        return justifyMap[justify] || 'justify-content-center';
    }
    getAlign(align) {
        const alignMap = {
            start: 'align-items-start',
            end: 'align-items-end',
            center: 'align-items-center',
            baseline: 'align-items-baseline',
            stretch: 'align-items-stretch'
        };
        return alignMap[align] || 'align-items-center';
    }
    getLayoutRowClass(row) {
        let className = '';
        if (row && row.class) {
            className = row.class;
        }
        return className;
    }
    getClass(layoutCol) {
        let className = '';
        if (layoutCol) {
            className = layoutCol.class;
        }
        className = className + ' '
            + this.getSizeClass(layoutCol.size) + ' '
            + this.getFontWeight(layoutCol.bold) + ' '
            + this.getColor(layoutCol.color);
        return className;
    }
    isEmptyFieldValue(fieldValue) {
        // Handle the cases, when input value is an string, array, objects or any other type
        if (typeof fieldValue === 'string') {
            fieldValue = fieldValue.trim();
        }
        return fieldValue == null
            || typeof fieldValue === 'undefined'
            || fieldValue === ''
            || fieldValue.length === 0;
    }
    getLabel(statisticMetadata, attribute) {
        let label = '';
        if (statisticMetadata && statisticMetadata[attribute]) {
            label = this.language.getFieldLabel(statisticMetadata[attribute]);
        }
        return label;
    }
    getLayout() {
        return this.gridWidgetInput.layout.rows;
    }
    buildStatistics() {
        this.gridWidgetInput.layout.rows.forEach(row => {
            if (!row.cols || !row.cols.length) {
                return;
            }
            row.cols.forEach(col => {
                if (!col.statistic) {
                    return;
                }
                if (col.store) {
                    this.statistics[col.statistic] = {
                        type: col.statistic,
                        store: col.store
                    };
                    return;
                }
                this.statistics[col.statistic] = {
                    type: col.statistic,
                    store: this.factory.create()
                };
                this.statistics[col.statistic].store.init(this.gridWidgetInput.queryArgs.module, {
                    key: col.statistic,
                    context: { ...this.gridWidgetInput.queryArgs.context },
                    params: { ...this.gridWidgetInput.queryArgs.params }
                }).pipe(take(1)).subscribe();
            });
        });
    }
    setupLoading$() {
        const loadings$ = [];
        Object.keys(this.statistics).forEach(type => loadings$.push(this.statistics[type].store.loading$));
        let statisticObs = of([]);
        if (loadings$.length < 1) {
            statisticObs = of([]);
        }
        else if (loadings$.length === 1) {
            statisticObs = loadings$[0].pipe(map(value => [value]));
        }
        else {
            let firsObs = null;
            let others;
            [firsObs, ...others] = loadings$;
            statisticObs = firsObs.pipe(combineLatestWith(others));
        }
        this.loading$ = statisticObs.pipe(map((loadings) => {
            if (!loadings || loadings.length < 1) {
                this.loading = false;
                return false;
            }
            let loading = true;
            loadings.forEach(value => {
                loading = loading && value;
            });
            this.loading = loading;
            return loading;
        }));
        this.subs.push(this.loading$.subscribe());
    }
    setupReload() {
        if (this.gridWidgetInput.widgetConfig.reload$) {
            this.subs.push(this.gridWidgetInput.widgetConfig.reload$.subscribe(() => {
                if (this.loading === false) {
                    this.loading = true;
                    Object.keys(this.statistics).forEach(statisticKey => {
                        const statistic = this.statistics[statisticKey];
                        if (!statistic.store) {
                            return;
                        }
                        statistic.store.load(false).pipe(take(1)).subscribe();
                    });
                }
            }));
        }
    }
    setupVM() {
        let allStatistics$ = of([]).pipe(shareReplay());
        const layout$ = of(this.getLayout()).pipe(shareReplay());
        if (this.statistics && Object.keys(this.statistics).length > 0) {
            const statistics$ = [];
            Object.keys(this.statistics).forEach(type => statistics$.push(this.statistics[type].store.state$));
            if (statistics$.length < 1) {
                allStatistics$ = of([]);
            }
            else if (statistics$.length === 1) {
                allStatistics$ = statistics$[0].pipe(map(value => [value]));
            }
            else {
                let firsObs = null;
                let others;
                [firsObs, ...others] = statistics$;
                allStatistics$ = firsObs.pipe(combineLatestWith(others));
            }
        }
        this.vm$ = allStatistics$.pipe(combineLatestWith(layout$), map(([statistics, layout]) => {
            const statsMap = {};
            const tooltipTitles = [];
            const descriptions = [];
            statistics.forEach(value => {
                statsMap[value.query.key] = value;
                const tooltip = this.getLabel(value.statistic.metadata, 'tooltip_title_key');
                if (tooltip) {
                    tooltipTitles.push(tooltip);
                }
                const description = this.getLabel(value.statistic.metadata, 'descriptionKey');
                if (description) {
                    descriptions.push(description);
                }
            });
            return {
                layout,
                statistics: statsMap,
                tooltipTitleText: tooltipTitles.join(' | '),
                description: descriptions.join(' | '),
            };
        }));
    }
    static { this.ɵfac = function GridWidgetComponent_Factory(t) { return new (t || GridWidgetComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SingleValueStatisticsStoreFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GridWidgetComponent, selectors: [["scrm-grid-widget"]], inputs: { config: "config" }, decls: 3, vars: 4, consts: [["class", "p-3 widget-message", 4, "ngIf"], ["class", "grid-widget d-flex flex-column", "placement", "auto", "container", "body", 3, "ngbTooltip", 4, "ngIf"], [1, "p-3", "widget-message"], [3, "labelKey"], ["placement", "auto", "container", "body", 1, "grid-widget", "d-flex", "flex-column", 3, "ngbTooltip"], [4, "ngFor", "ngForOf"], [3, "class", 4, "ngFor", "ngForOf"], [4, "ngIf"], [1, "widget-entry-icon"], [3, "image", "klass"], ["class", "widget-entry-value", 4, "ngIf"], ["class", "widget-entry-loading", 4, "ngIf"], [1, "widget-entry-value"], ["mode", "list", 3, "type", "field"], [1, "widget-entry-loading"], [1, "widget-entry-label", "text-truncate"], [3, "labelKey", "module"], [1, "text-truncate", "widget-entry-label"], ["class", "widget-entry-dynamic-label", 4, "ngIf"], [1, "widget-entry-dynamic-label"], [3, "context", "fields", "labelKey"]], template: function GridWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, GridWidgetComponent_div_0_Template, 2, 1, "div", 0);
            i0.ɵɵtemplate(1, GridWidgetComponent_div_1_Template, 2, 2, "div", 1);
            i0.ɵɵpipe(2, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.messageLabelKey);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.messageLabelKey && i0.ɵɵpipeBind1(2, 2, ctx.vm$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, FieldComponent, InlineLoadingSpinnerComponent, LabelComponent, ImageComponent, DynamicLabelComponent, i3$1.NgbTooltip, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GridWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-grid-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"this.messageLabelKey\" class=\"p-3 widget-message\">\n    <scrm-label [labelKey]=\"this.messageLabelKey\"></scrm-label>\n</div>\n\n<div *ngIf=\"!this.messageLabelKey && (vm$| async) as vm\"\n     class=\"grid-widget d-flex flex-column\"\n     ngbTooltip=\"{{vm.tooltipTitleText}}\" placement=\"auto\" container=\"body\">\n\n    <ng-container *ngFor=\"let item of vm.layout\">\n\n        <div\n            class=\"d-flex {{getJustify(item.justify)}} {{getAlign(item.align)}} {{getRowClass()}} {{getLayoutRowClass(item)}}\">\n\n            <div class=\"{{getColClass()}} {{getClass(col)}}\" *ngFor=\"let col of item.cols\">\n\n                <ng-container *ngIf=\"col.display !== 'hidden'\">\n\n                    <!-- ICON -->\n                    <ng-container *ngIf=\"col.icon\">\n                        <div class=\"widget-entry-icon\">\n                            <scrm-image [image]=\"col.icon\" [klass]=\"col.iconClass\"></scrm-image>\n                        </div>\n                    </ng-container>\n\n                    <!-- VALUE -->\n                    <ng-container *ngIf=\"col.statistic && (vm.statistics[col.statistic]) as statistics\">\n\n                        <div *ngIf=\"statistics.field\" class=\"widget-entry-value\">\n\n                            <scrm-field [type]=\"statistics.field.type\"\n                                        [field]=\"statistics.field\"\n                                        mode=\"list\">\n                            </scrm-field>\n\n                        </div>\n                        <div *ngIf=\"statistics.loading && loading\" class=\"widget-entry-loading\">\n\n                            <scrm-inline-loading-spinner></scrm-inline-loading-spinner>\n\n                        </div>\n                    </ng-container>\n\n                    <!-- LABEL -->\n                    <ng-container *ngIf=\"col.labelKey\">\n\n                        <div class=\"widget-entry-label text-truncate\">\n\n                            <scrm-label [labelKey]=\"col.labelKey\" [module]=\"getContextModule()\"></scrm-label>\n\n                        </div>\n\n                    </ng-container>\n\n                    <!-- DESCRIPTION TEXT -->\n                    <ng-container *ngIf=\"col.descriptionKey\">\n\n                        <div class=\"text-truncate widget-entry-label\">\n\n                            <label>{{vm.description}}</label>\n\n                        </div>\n\n                    </ng-container>\n\n                    <!-- DYNAMIC LABEL -->\n                    <ng-container *ngIf=\"col.dynamicLabel\">\n\n                        <div *ngIf=\"!loading\" class=\"widget-entry-dynamic-label\">\n\n                            <scrm-dynamic-label [context]=\"getMessageContext()\"\n                                                [fields]=\"getMessageFields(vm.statistics)\"\n                                                [labelKey]=\"col.dynamicLabel\">\n                            </scrm-dynamic-label>\n\n                        </div>\n\n                        <div *ngIf=\"loading\" class=\"widget-entry-loading\">\n                            <scrm-inline-loading-spinner></scrm-inline-loading-spinner>\n                        </div>\n\n                    </ng-container>\n\n                    <!-- MISCONFIGURATION -->\n                    <ng-container\n                        *ngIf=\"col.statistic && !loading && (!vm.statistics[col.statistic].field || (vm.statistics[col.statistic].field && isEmptyFieldValue(vm.statistics[col.statistic].field.value)))\">\n                        <div class=\"widget-entry-value {{getSizeClass(col.size)}}\">\n                            -\n                        </div>\n                    </ng-container>\n\n                </ng-container>\n\n            </div>\n\n        </div>\n    </ng-container>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: SingleValueStatisticsStoreFactory }]; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function MinimiseButtonComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r0.internalConfig);
} }
class MinimiseButtonComponent {
    constructor() {
        this.status = 'maximised';
        this.buttonClasses = ['minimise-button'];
    }
    ngOnInit() {
        this.buildButton();
    }
    ngOnChanges(changes) {
        if (changes.config) {
            this.buildButton();
        }
    }
    buildButton() {
        const btn = Button.fromButton(this.config);
        btn.addClasses(this.buttonClasses);
        btn.icon = this.getIcon();
        btn.onClick = () => {
            this.config.onClick();
            this.toggleStatus();
        };
        this.internalConfig = btn;
    }
    toggleStatus() {
        let newStatus = 'minimised';
        if (this.status === 'minimised') {
            newStatus = 'maximised';
        }
        this.status = newStatus;
        this.buildButton();
    }
    getIcon() {
        if (this.status === 'minimised') {
            return 'plus_thin';
        }
        return 'minimise';
    }
    static { this.ɵfac = function MinimiseButtonComponent_Factory(t) { return new (t || MinimiseButtonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MinimiseButtonComponent, selectors: [["scrm-minimise-button"]], inputs: { config: "config", status: "status" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [3, "config"]], template: function MinimiseButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MinimiseButtonComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.internalConfig);
        } }, dependencies: [i2.NgIf, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MinimiseButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-minimise-button', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"internalConfig\">\n    <scrm-button [config]=\"internalConfig\"></scrm-button>\n</ng-container>\n" }]
    }], function () { return []; }, { config: [{
            type: Input
        }], status: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function PanelComponent_div_1_scrm_close_button_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-close-button", 9);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config", ctx_r1.getCloseButton());
} }
function PanelComponent_div_1_scrm_minimise_button_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-minimise-button", 10);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config", ctx_r2.minimiseButton)("status", ctx_r2.minimiseStatus);
} }
function PanelComponent_div_1_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r3.title);
} }
function PanelComponent_div_1_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵelement(1, "scrm-label", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r4.titleKey);
} }
function PanelComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2)(1, "div", 3)(2, "div", 4);
    i0.ɵɵtemplate(3, PanelComponent_div_1_scrm_close_button_3_Template, 1, 1, "scrm-close-button", 5);
    i0.ɵɵtemplate(4, PanelComponent_div_1_scrm_minimise_button_4_Template, 1, 2, "scrm-minimise-button", 6);
    i0.ɵɵprojection(5, 1);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(6, PanelComponent_div_1_div_6_Template, 2, 1, "div", 7);
    i0.ɵɵtemplate(7, PanelComponent_div_1_div_7_Template, 2, 1, "div", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "div", 8);
    i0.ɵɵprojection(9, 2);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r0.isClosable());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.isCollapsible());
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.title);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.titleKey);
} }
const _c0$v = [[["", "panel-body", ""]], [["", "panel-icon-area", ""]], [["", "panel-header-button", ""]]];
const _c1$8 = ["[panel-body]", "[panel-icon-area]", "[panel-header-button]"];
class PanelComponent {
    constructor() {
        this.klass = '';
        this.bodyPadding = 2;
        this.mode = 'closable';
        this.close = {
            klass: ['btn', 'btn-outline-light', 'btn-sm']
        };
        this.showHeader = true;
        this.isCollapsed = false;
        this.buttonClasses = ['btn', 'btn-outline-light', 'btn-sm'];
        this.subs = [];
    }
    ngOnInit() {
        if (this.isCollapsed$) {
            this.subs.push(this.isCollapsed$.subscribe(collapse => {
                this.isCollapsed = collapse;
                this.initMinimiseButton();
            }));
        }
        this.initMinimiseButton();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getCloseButton() {
        if (!this.close) {
            return null;
        }
        const btn = Button.fromButton(this.close);
        btn.addClasses(this.buttonClasses);
        this.close = btn;
        return btn;
    }
    isClosable() {
        return this.mode === 'closable';
    }
    isCollapsible() {
        return this.mode === 'collapsible';
    }
    initMinimiseButton() {
        this.minimiseButton = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.isCollapsed = !this.isCollapsed;
                this.initMinimiseStatus();
            },
        };
        this.initMinimiseStatus();
    }
    initMinimiseStatus() {
        if (this.isCollapsed) {
            this.minimiseStatus = 'minimised';
            return;
        }
        this.minimiseStatus = 'maximised';
    }
    static { this.ɵfac = function PanelComponent_Factory(t) { return new (t || PanelComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PanelComponent, selectors: [["scrm-panel"]], inputs: { klass: "klass", bodyPadding: "bodyPadding", title: "title", titleKey: "titleKey", mode: "mode", isCollapsed$: "isCollapsed$", close: "close", showHeader: "showHeader" }, ngContentSelectors: _c1$8, decls: 4, vars: 10, consts: [["class", "card-header d-flex justify-content-between align-items-center", 4, "ngIf"], [3, "ngbCollapse"], [1, "card-header", "d-flex", "justify-content-between", "align-items-center"], [1, "flex-grow-1", "align-items-center", "d-flex"], [1, "d-flex", "align-items-center"], [3, "config", 4, "ngIf"], [3, "config", "status", 4, "ngIf"], ["class", "pl-1 panel-title", 4, "ngIf"], [1, "panel-buttons", "float-right"], [3, "config"], [3, "config", "status"], [1, "pl-1", "panel-title"], [3, "labelKey"]], template: function PanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$v);
            i0.ɵɵelementStart(0, "div");
            i0.ɵɵtemplate(1, PanelComponent_div_1_Template, 10, 4, "div", 0);
            i0.ɵɵelementStart(2, "div", 1);
            i0.ɵɵprojection(3);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵclassMapInterpolate1("card panel-card ", ctx.klass, "");
            i0.ɵɵclassProp("collapsed", ctx.isCollapsed);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.showHeader);
            i0.ɵɵadvance(1);
            i0.ɵɵclassMapInterpolate1("card-body p-", ctx.bodyPadding, "");
            i0.ɵɵproperty("ngbCollapse", ctx.isCollapsed);
        } }, dependencies: [i2.NgIf, CloseButtonComponent, i3$1.NgbCollapse, MinimiseButtonComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PanelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-panel', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div [class.collapsed]=\"isCollapsed\" class=\"card panel-card {{klass}}\">\n\n    <div *ngIf=\"showHeader\" class=\"card-header d-flex justify-content-between align-items-center\">\n\n        <div class=\"flex-grow-1 align-items-center d-flex\">\n\n            <div class=\"d-flex align-items-center\">\n                <scrm-close-button *ngIf=\"isClosable()\" [config]=\"getCloseButton()\"></scrm-close-button>\n                <scrm-minimise-button *ngIf=\"isCollapsible()\"\n                                      [config]=\"minimiseButton\"\n                                      [status]=\"minimiseStatus\">\n                </scrm-minimise-button>\n                <ng-content select=\"[panel-icon-area]\"></ng-content>\n            </div>\n\n            <div *ngIf=\"title\" class=\"pl-1 panel-title\">{{title}}</div>\n            <div *ngIf=\"titleKey\" class=\"pl-1 panel-title\">\n                <scrm-label [labelKey]=\"titleKey\"></scrm-label>\n            </div>\n        </div>\n\n\n        <div class=\"panel-buttons float-right\">\n            <ng-content select=\"[panel-header-button]\"></ng-content>\n        </div>\n    </div>\n\n    <div class=\"card-body p-{{bodyPadding}}\" [ngbCollapse]=\"isCollapsed\">\n        <ng-content select=\"[panel-body]\"></ng-content>\n    </div>\n</div>\n" }]
    }], function () { return []; }, { klass: [{
            type: Input
        }], bodyPadding: [{
            type: Input
        }], title: [{
            type: Input
        }], titleKey: [{
            type: Input
        }], mode: [{
            type: Input
        }], isCollapsed$: [{
            type: Input
        }], close: [{
            type: Input
        }], showHeader: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function WidgetPanelComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵprojection(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("@widgetContentFade", ctx_r0.displayContent ? "true" : "false");
} }
const _c0$u = [[["", "widget-body", ""]]];
const _c1$7 = ["[widget-body]"];
class WidgetPanelComponent {
    constructor(languageStore) {
        this.languageStore = languageStore;
        this.title = '';
        this.mode = 'none';
        this.displayContent = true;
    }
    ngOnInit() {
    }
    static { this.ɵfac = function WidgetPanelComponent_Factory(t) { return new (t || WidgetPanelComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WidgetPanelComponent, selectors: [["scrm-widget-panel"]], inputs: { title: "title", mode: "mode" }, ngContentSelectors: _c1$7, decls: 5, vars: 3, consts: [[1, "accordion", "widget-panel", "mr-0", "shadow-sm"], ["bodyPadding", "0", 3, "mode", "title"], ["panel-header-button", ""], ["panel-body", ""], ["class", "widget collapse show open-close-container", "data-parent", ".widget-panel", 4, "ngIf"], ["data-parent", ".widget-panel", 1, "widget", "collapse", "show", "open-close-container"]], template: function WidgetPanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$u);
            i0.ɵɵelementStart(0, "div", 0)(1, "scrm-panel", 1);
            i0.ɵɵelement(2, "span", 2);
            i0.ɵɵelementStart(3, "div", 3);
            i0.ɵɵtemplate(4, WidgetPanelComponent_div_4_Template, 2, 1, "div", 4);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("mode", ctx.mode)("title", ctx.title);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.displayContent);
        } }, dependencies: [i2.NgIf, PanelComponent], encapsulation: 2, data: { animation: [
                trigger('widgetFade', [
                    transition('void => *', [
                        style({ transform: 'translateX(100%)', opacity: 0 }),
                        animate('500ms', style({ transform: 'translateX(0)', opacity: 1 }))
                    ]),
                    transition('* => void', [
                        style({ transform: 'translateX(0)', opacity: 1 }),
                        animate('500ms', style({ transform: 'translateX(100%)', opacity: 0 }))
                    ])
                ]),
                trigger('widgetContentFade', [
                    transition('void => *', [
                        style({ transform: 'translateY(-5%)', opacity: 0 }),
                        animate('500ms', style({ transform: 'translateY(0)', opacity: 1 }))
                    ]),
                    transition('* => void', [
                        style({ transform: 'translateY(0)', opacity: 1 }),
                        animate('500ms', style({ transform: 'translateY(-5%)', opacity: 0 }))
                    ])
                ])
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WidgetPanelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-widget-panel', animations: [
                    trigger('widgetFade', [
                        transition('void => *', [
                            style({ transform: 'translateX(100%)', opacity: 0 }),
                            animate('500ms', style({ transform: 'translateX(0)', opacity: 1 }))
                        ]),
                        transition('* => void', [
                            style({ transform: 'translateX(0)', opacity: 1 }),
                            animate('500ms', style({ transform: 'translateX(100%)', opacity: 0 }))
                        ])
                    ]),
                    trigger('widgetContentFade', [
                        transition('void => *', [
                            style({ transform: 'translateY(-5%)', opacity: 0 }),
                            animate('500ms', style({ transform: 'translateY(0)', opacity: 1 }))
                        ]),
                        transition('* => void', [
                            style({ transform: 'translateY(0)', opacity: 1 }),
                            animate('500ms', style({ transform: 'translateY(-5%)', opacity: 0 }))
                        ])
                    ])
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"accordion widget-panel mr-0 shadow-sm\">\n    <scrm-panel [mode]=\"mode\" [title]=\"title\" bodyPadding=\"0\">\n        <span panel-header-button>\n        </span>\n        <div panel-body>\n            <div *ngIf=\"displayContent\"\n                 class=\"widget collapse show open-close-container\"\n                 data-parent=\".widget-panel\"\n                 [@widgetContentFade]=\"displayContent ? 'true' : 'false'\">\n                <ng-content select=\"[widget-body]\"></ng-content>\n            </div>\n        </div>\n    </scrm-panel>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { title: [{
            type: Input
        }], mode: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MinimiseButtonModule {
    static { this.ɵfac = function MinimiseButtonModule_Factory(t) { return new (t || MinimiseButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MinimiseButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MinimiseButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [MinimiseButtonComponent],
                exports: [
                    MinimiseButtonComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MinimiseButtonModule, { declarations: [MinimiseButtonComponent], imports: [CommonModule,
        ButtonModule], exports: [MinimiseButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PanelModule {
    static { this.ɵfac = function PanelModule_Factory(t) { return new (t || PanelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PanelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            CloseButtonModule,
            NgbModule,
            MinimiseButtonModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PanelModule, [{
        type: NgModule,
        args: [{
                declarations: [PanelComponent],
                exports: [
                    PanelComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    CloseButtonModule,
                    NgbModule,
                    MinimiseButtonModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PanelModule, { declarations: [PanelComponent], imports: [CommonModule,
        ButtonModule,
        CloseButtonModule,
        NgbModule,
        MinimiseButtonModule,
        LabelModule], exports: [PanelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class WidgetPanelModule {
    static { this.ɵfac = function WidgetPanelModule_Factory(t) { return new (t || WidgetPanelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: WidgetPanelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule,
            PanelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WidgetPanelModule, [{
        type: NgModule,
        args: [{
                declarations: [WidgetPanelComponent],
                exports: [WidgetPanelComponent],
                imports: [
                    CommonModule,
                    ImageModule,
                    PanelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(WidgetPanelModule, { declarations: [WidgetPanelComponent], imports: [CommonModule,
        ImageModule,
        PanelModule], exports: [WidgetPanelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GridWidgetModule {
    static { this.ɵfac = function GridWidgetModule_Factory(t) { return new (t || GridWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GridWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            InlineLoadingSpinnerModule,
            WidgetPanelModule,
            LabelModule,
            ImageModule,
            DynamicLabelModule,
            NgbTooltipModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GridWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [GridWidgetComponent],
                exports: [
                    GridWidgetComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    InlineLoadingSpinnerModule,
                    WidgetPanelModule,
                    LabelModule,
                    ImageModule,
                    DynamicLabelModule,
                    NgbTooltipModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(GridWidgetModule, { declarations: [GridWidgetComponent], imports: [CommonModule,
        FieldModule,
        InlineLoadingSpinnerModule,
        WidgetPanelModule,
        LabelModule,
        ImageModule,
        DynamicLabelModule,
        NgbTooltipModule], exports: [GridWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function InstallErrorModalComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5)(1, "div", 6)(2, "strong");
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(4, "div", 7);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r0.getColumnLabel("LBL_CHECKSYS_TITLE"));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r0.getColumnLabel("ERR_CHECKSYS"), " ");
} }
function InstallErrorModalComponent_li_6_span_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 14)(1, "strong");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r2 = i0.ɵɵnextContext().$implicit;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.getColumnLabel(item_r2.value.info), " ");
} }
function InstallErrorModalComponent_li_6_div_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r2 = i0.ɵɵnextContext().$implicit;
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r4.getColumnLabel(item_r2.value.error), " ");
} }
function InstallErrorModalComponent_li_6_div_9_li_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const subItems_r9 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", subItems_r9, " ");
} }
function InstallErrorModalComponent_li_6_div_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15)(1, "ul");
    i0.ɵɵtemplate(2, InstallErrorModalComponent_li_6_div_9_li_2_Template, 2, 1, "li", 4);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r2 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", item_r2.value.data);
} }
function InstallErrorModalComponent_li_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li")(1, "div", 8)(2, "div")(3, "span");
    i0.ɵɵelement(4, "scrm-image", 9);
    i0.ɵɵelementStart(5, "strong", 10);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(7, InstallErrorModalComponent_li_6_span_7_Template, 3, 1, "span", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(8, InstallErrorModalComponent_li_6_div_8_Template, 2, 1, "div", 12);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(9, InstallErrorModalComponent_li_6_div_9_Template, 3, 1, "div", 13);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r2 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("alert ", ctx_r1.getAlertType(item_r2.value), "");
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("image", ctx_r1.getAlertIcon(item_r2.value));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.getColumnLabel(item_r2.value.label), " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r2.value.info !== "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r2.value.error !== "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r2.value.data.length !== 0);
} }
const alertTypes = {
    success: {
        alertClass: 'alert-success',
        alertIcon: 'info-circle'
    },
    error: {
        alertClass: 'alert-danger',
        alertIcon: 'exclamation-circle'
    },
    warning: {
        alertClass: 'alert-warning',
        alertIcon: 'exclamation-triangle'
    },
    info: {
        alertClass: 'alert-info',
        alertIcon: 'info-circle'
    },
    light: {
        alertClass: 'alert-light',
        alertIcon: 'exclamation-circle'
    }
};
class InstallErrorModalComponent {
    constructor(appState, languageStore, modal) {
        this.appState = appState;
        this.languageStore = languageStore;
        this.modal = modal;
        this.titleKey = 'LBL_CHECKSYS_TITLE';
    }
    getHeaderLabel() {
        return this.languageStore.getFieldLabel('LBL_CHECKSYS_TITLE');
    }
    getColumnLabel(label) {
        const langLabel = this.languageStore.getFieldLabel(label, this.appState.getModule());
        return !isEmptyString(langLabel) ? langLabel : label;
    }
    ngOnInit() {
        this.closeButtonIcon = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.modal.close({
                    type: 'close-button'
                });
            }
        };
        this.closeButton = {
            klass: ['btn', 'modal-button-cancel'],
            labelKey: 'LBL_COLUMN_SELECTOR_CLOSE_BUTTON',
            onClick: () => {
                this.modal.close({
                    type: 'close-button'
                });
            }
        };
    }
    getAlertType(alert) {
        if (alert.status === 'error') {
            return alertTypes[alert.type]['alertClass'];
        }
        return alertTypes[alert.status]['alertClass'];
    }
    getAlertIcon(alert) {
        if (alert.status === 'error') {
            return alertTypes[alert.type]['alertIcon'];
        }
        return alertTypes[alert.status]['alertIcon'];
    }
    returnZero() {
        return 0;
    }
    static { this.ɵfac = function InstallErrorModalComponent_Factory(t) { return new (t || InstallErrorModalComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(i3$1.NgbActiveModal)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: InstallErrorModalComponent, selectors: [["scrm-install-error-modal"]], inputs: { errors: "errors" }, decls: 8, vars: 11, consts: [[3, "closable", "close", "title", "titleKey", "headerKlass", "bodyKlass"], ["modal-body", ""], ["class", "alert alert-danger", "role", "alert", 4, "ngIf"], [1, "list-style-none"], [4, "ngFor", "ngForOf"], ["role", "alert", 1, "alert", "alert-danger"], [1, "alert-heading"], [1, "alert-desc"], ["role", "alert"], [3, "image"], [2, "margin-left", "2px"], ["style", "float:right", 4, "ngIf"], [4, "ngIf"], ["class", "alert alert-light", "role", "alert", 4, "ngIf"], [2, "float", "right"], ["role", "alert", 1, "alert", "alert-light"]], template: function InstallErrorModalComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-modal", 0)(1, "div", 1);
            i0.ɵɵelementContainerStart(2);
            i0.ɵɵtemplate(3, InstallErrorModalComponent_div_3_Template, 6, 2, "div", 2);
            i0.ɵɵelementStart(4, "div")(5, "ul", 3);
            i0.ɵɵtemplate(6, InstallErrorModalComponent_li_6_Template, 10, 8, "li", 4);
            i0.ɵɵpipe(7, "keyvalue");
            i0.ɵɵelementEnd()();
            i0.ɵɵelementContainerEnd();
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("closable", true)("close", ctx.closeButtonIcon)("title", ctx.getHeaderLabel())("titleKey", ctx.titleKey)("headerKlass", "alert-header")("bodyKlass", "alert-body");
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.errors["hasValidationError"] && ctx.errors["hasValidationError"] === true);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(7, 8, ctx.errors["data"], ctx.returnZero));
        } }, dependencies: [i2.NgForOf, i2.NgIf, ModalComponent, ImageComponent, i2.KeyValuePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallErrorModalComponent, [{
        type: Component,
        args: [{ selector: 'scrm-install-error-modal', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<scrm-modal\n    [closable]=\"true\"\n    [close]=\"closeButtonIcon\"\n    [title]=\"getHeaderLabel()\"\n    [titleKey]=\"titleKey\"\n    [headerKlass]=\"'alert-header'\"\n    [bodyKlass]=\"'alert-body'\">\n\n    <div modal-body>\n        <ng-container>\n            <div *ngIf=\"errors['hasValidationError'] && errors['hasValidationError'] === true\"\n                 class=\"alert alert-danger\" role=\"alert\">\n\n                <div class=\"alert-heading\">\n                    <strong>{{getColumnLabel('LBL_CHECKSYS_TITLE')}}</strong>\n                </div>\n                <div class=\"alert-desc\">\n                    {{getColumnLabel('ERR_CHECKSYS')}}\n                </div>\n            </div>\n\n            <div>\n                <ul class=\"list-style-none\">\n\n                    <li *ngFor=\"let item of errors['data'] | keyvalue : returnZero\">\n\n                        <div class=\"alert {{getAlertType(item.value)}}\" role=\"alert\">\n\n                            <div>\n                                <span>\n                                    <scrm-image [image]=\"getAlertIcon(item.value)\"></scrm-image>\n                                    <strong style=\"margin-left: 2px;\">\n                                        {{getColumnLabel(item.value.label)}}\n                                    </strong>\n                                </span>\n\n                                <span *ngIf=\"item.value.info!==''\" style=\"float:right\">\n                                    <strong>\n                                        {{getColumnLabel(item.value.info)}}\n                                    </strong>\n                                </span>\n                            </div>\n\n                            <div *ngIf=\"item.value.error!==''\">\n                                {{getColumnLabel(item.value.error)}}\n                            </div>\n                        </div>\n\n                        <div *ngIf=\"item.value.data.length!==0\" class=\"alert alert-light\" role=\"alert\">\n                            <ul>\n                                <li *ngFor=\"let subItems of item.value.data\">\n                                    {{subItems}}\n                                </li>\n                            </ul>\n                        </div>\n\n                    </li>\n                </ul>\n            </div>\n        </ng-container>\n    </div>\n</scrm-modal>\n\n" }]
    }], function () { return [{ type: AppStateStore }, { type: LanguageStore }, { type: i3$1.NgbActiveModal }]; }, { errors: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallErrorModalModule {
    static { this.ɵfac = function InstallErrorModalModule_Factory(t) { return new (t || InstallErrorModalModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: InstallErrorModalModule, bootstrap: [InstallErrorModalComponent] }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            DragDropModule,
            CloseButtonModule,
            ModalModule,
            LabelModule,
            ButtonModule,
            NgbModule,
            NgbAlertModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallErrorModalModule, [{
        type: NgModule,
        args: [{
                declarations: [InstallErrorModalComponent],
                exports: [InstallErrorModalComponent],
                imports: [
                    CommonModule,
                    DragDropModule,
                    CloseButtonModule,
                    ModalModule,
                    LabelModule,
                    ButtonModule,
                    NgbModule,
                    NgbAlertModule,
                    ImageModule
                ],
                bootstrap: [InstallErrorModalComponent]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(InstallErrorModalModule, { declarations: [InstallErrorModalComponent], imports: [CommonModule,
        DragDropModule,
        CloseButtonModule,
        ModalModule,
        LabelModule,
        ButtonModule,
        NgbModule,
        NgbAlertModule,
        ImageModule], exports: [InstallErrorModalComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LineActionMenuComponent_ng_container_0_scrm_button_group_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button-group", 7);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config$", ctx_r1.config$)("klass", "icon-bar-block");
} }
function LineActionMenuComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 1)(2, "div", 2)(3, "div", 3)(4, "div");
    i0.ɵɵtemplate(5, LineActionMenuComponent_ng_container_0_scrm_button_group_5_Template, 1, 2, "scrm-button-group", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "button", 5);
    i0.ɵɵlistener("click", function LineActionMenuComponent_ng_container_0_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.toggleExpand(ctx_r2.record == null ? null : ctx_r2.record.id)); });
    i0.ɵɵelement(7, "scrm-image", 6);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵclassMap(ctx_r0.wrapperClass);
    i0.ɵɵproperty("ngClass", ctx_r0.isActive ? "active" : "");
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap(ctx_r0.klass);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.config$);
} }
class LineActionMenuComponent {
    onClickOutside(target) {
        if (!this.el.nativeElement.contains(target)) {
            this.isActive = false;
            this.isClickedOutside.set(true);
        }
    }
    constructor(languageStore, languages, screenSize, systemConfigStore, el) {
        this.languageStore = languageStore;
        this.languages = languages;
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.el = el;
        this.klass = '';
        this.wrapperClass = '';
        this.limitConfigKey = 'listview_line_actions_limits';
        this.configState = new BehaviorSubject({ buttons: [] });
        this.config$ = this.configState.asObservable();
        this.isActive = false;
        this.isClickedOutside = signal(false);
        this.buttonClass = 'line-action-item line-action';
        this.buttonGroupClass = 'float-right';
        this.subs = [];
        this.screen = ScreenSize.Medium;
        this.defaultBreakpoint = 3;
    }
    ngOnInit() {
        this.subs.push(this.config.getActions({ record: this.record }).pipe(combineLatestWith(this.screenSize.screenSize$, this.languages.vm$), map(([actions, screenSize, languages]) => {
            if (screenSize) {
                this.screen = screenSize;
            }
            this.configState.next(this.getButtonGroupConfig(actions));
            this.actions = actions;
        })).subscribe());
        this.subs.push(this.activeLineAction.activeAction$.subscribe((activeAction) => {
            if (this.record?.id === activeAction) {
                this.isActive = true;
            }
            else {
                this.isActive = false;
            }
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.isActive = false;
        this.activeLineAction.resetActiveAction();
    }
    getButtonGroupConfig(actions) {
        const expanded = [];
        const collapsed = [];
        actions.forEach((action) => {
            const button = this.buildButton(action);
            if (action.params && action.params.expanded) {
                expanded.push(button);
                return;
            }
            collapsed.push(button);
        });
        let breakpoint = actions.length;
        const buttons = expanded.concat(collapsed);
        return {
            buttonKlass: [this.buttonClass],
            dropdownLabel: this.languages.getAppString('LBL_ACTIONS') || '',
            breakpoint,
            dropdownOptions: {
                placement: ['bottom-right'],
                wrapperKlass: [(this.buttonGroupClass)]
            },
            buttons
        };
    }
    getBreakpoint() {
        const breakpointMap = this.systemConfigStore.getConfigValue(this.limitConfigKey);
        if (this.screen && breakpointMap && breakpointMap[this.screen]) {
            this.breakpoint = breakpointMap[this.screen];
            return this.breakpoint;
        }
        if (this.breakpoint) {
            return this.breakpoint;
        }
        return this.defaultBreakpoint;
    }
    buildButton(action) {
        const button = {
            titleKey: action.labelKey || '',
            klass: this.buttonClass,
            icon: action.icon || '',
            onClick: () => {
                this.config.runAction(action, {
                    module: (this.record && this.record.module) || '',
                    record: this.record
                });
            }
        };
        if (action.icon) {
            button.icon = action.icon;
        }
        const debounceClick = action?.params?.debounceClick ?? null;
        button.debounceClick = true;
        if (isFalse(debounceClick)) {
            button.debounceClick = false;
        }
        if (action.status) {
            Button.appendClasses(button, [action.status]);
        }
        return button;
    }
    toggleExpand(recordId) {
        const activeId = this.activeLineAction.getActiveAction();
        if (activeId === recordId && !this.isClickedOutside()) {
            this.activeLineAction.resetActiveAction();
        }
        else {
            this.activeLineAction.setActiveAction(recordId);
            this.isActive = true;
            this.isClickedOutside.set(false);
        }
    }
    static { this.ɵfac = function LineActionMenuComponent_Factory(t) { return new (t || LineActionMenuComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(i0.ElementRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LineActionMenuComponent, selectors: [["scrm-line-action-menu"]], hostBindings: function LineActionMenuComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("click", function LineActionMenuComponent_click_HostBindingHandler($event) { return ctx.onClickOutside($event.target); }, false, i0.ɵɵresolveDocument);
        } }, inputs: { klass: "klass", wrapperClass: "wrapperClass", record: "record", config: "config", activeLineAction: "activeLineAction", limitConfigKey: "limitConfigKey" }, decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "line-action-container"], ["id", "line-action-div", 1, "line-action", "line-action-position"], [3, "ngClass"], [3, "config$", "klass", 4, "ngIf"], ["aria-label", "Mobile Menu Button", 1, "more-button", 3, "click"], ["image", "apps-line", 1, "sicon"], [3, "config$", "klass"]], template: function LineActionMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LineActionMenuComponent_ng_container_0_Template, 8, 8, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.actions.length);
        } }, dependencies: [i2.NgClass, i2.NgIf, ImageComponent, ButtonGroupComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineActionMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-line-action-menu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"actions.length\">\n    <div class=\"line-action-container\">\n        <div id=\"line-action-div\" class=\"line-action line-action-position\">\n            <div class=\"{{wrapperClass}}\" [ngClass]=\"isActive ? 'active': ''\">\n                <div class=\"{{klass}}\">\n                    <scrm-button-group *ngIf=\"config$\" [config$]=\"config$\" [klass]=\"'icon-bar-block'\"></scrm-button-group>\n                </div>\n                <button class=\"more-button\" aria-label=\"Mobile Menu Button\" (click)=\"toggleExpand(record?.id)\">\n                    <scrm-image class=\"sicon\" image=\"apps-line\"></scrm-image>\n                </button>\n            </div>\n        </div>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: LanguageStore }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }, { type: i0.ElementRef }]; }, { klass: [{
            type: Input
        }], wrapperClass: [{
            type: Input
        }], record: [{
            type: Input
        }], config: [{
            type: Input
        }], activeLineAction: [{
            type: Input
        }], limitConfigKey: [{
            type: Input
        }], onClickOutside: [{
            type: HostListener,
            args: ['document:click', ['$event.target']]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineActionModule {
    static { this.ɵfac = function LineActionModule_Factory(t) { return new (t || LineActionModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LineActionModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgbModule,
            ImageModule,
            RouterModule,
            ButtonGroupModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineActionModule, [{
        type: NgModule,
        args: [{
                declarations: [LineActionMenuComponent],
                exports: [LineActionMenuComponent],
                imports: [
                    CommonModule,
                    NgbModule,
                    ImageModule,
                    RouterModule,
                    ButtonGroupModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LineActionModule, { declarations: [LineActionMenuComponent], imports: [CommonModule,
        NgbModule,
        ImageModule,
        RouterModule,
        ButtonGroupModule], exports: [LineActionMenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadMoreComponent {
    static { this.ɵfac = function LoadMoreComponent_Factory(t) { return new (t || LoadMoreComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LoadMoreComponent, selectors: [["scrm-load-more"]], inputs: { loadMoreButton: "loadMoreButton" }, decls: 3, vars: 1, consts: [[1, "float-right"], [1, "", 3, "config"], ["image", "plus_thin", 1, "small", 2, "fill", "#FFFFFF"]], template: function LoadMoreComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "scrm-button", 1);
            i0.ɵɵelement(2, "scrm-image", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.loadMoreButton);
        } }, dependencies: [ImageComponent, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadMoreComponent, [{
        type: Component,
        args: [{ selector: 'scrm-load-more', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"float-right\">\n    <scrm-button [config]=\"loadMoreButton\" class=\"\">\n        <scrm-image class=\"small\" style=\"fill: #FFFFFF\" image=\"plus_thin\">\n        </scrm-image>\n    </scrm-button>\n</div>\n" }]
    }], null, { loadMoreButton: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoadMoreModule {
    static { this.ɵfac = function LoadMoreModule_Factory(t) { return new (t || LoadMoreModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LoadMoreModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoadMoreModule, [{
        type: NgModule,
        args: [{
                declarations: [LoadMoreComponent],
                exports: [LoadMoreComponent],
                imports: [
                    CommonModule,
                    ImageModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LoadMoreModule, { declarations: [LoadMoreComponent], imports: [CommonModule,
        ImageModule,
        ButtonModule], exports: [LoadMoreComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoAbstract {
    constructor() {
        this.url = ''; // todo: using a preloader url till logo is loading?
        this.md5 = '';
        this.width = 0;
        this.height = 0;
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoUiComponent {
    static { this.ɵfac = function LogoUiComponent_Factory(t) { return new (t || LogoUiComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LogoUiComponent, selectors: [["scrm-logo-ui"]], decls: 1, vars: 0, consts: [["image", "company_logo", 1, "logo"]], template: function LogoUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "scrm-image", 0);
        } }, dependencies: [ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-logo-ui', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-image image=\"company_logo\" class=\"logo\"></scrm-image>\n" }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoUiModule {
    static { this.ɵfac = function LogoUiModule_Factory(t) { return new (t || LogoUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LogoUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoUiModule, [{
        type: NgModule,
        args: [{
                declarations: [LogoUiComponent],
                exports: [LogoUiComponent],
                imports: [
                    CommonModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LogoUiModule, { declarations: [LogoUiComponent], imports: [CommonModule,
        ImageModule], exports: [LogoUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LogoutUiComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 1);
    i0.ɵɵlistener("click", function LogoutUiComponent_ng_container_0_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r3); const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.doLogout()); });
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(vm_r1.appStrings[ctx_r0.logout.logoutAction.label] || "");
} }
class LogoutUiComponent {
    constructor(auth, languageStore) {
        this.auth = auth;
        this.languageStore = languageStore;
        this.logout = {
            logoutAction: {
                label: 'LBL_LOGOUT'
            }
        };
        this.languages$ = this.languageStore.vm$;
        this.vm$ = this.languages$.pipe(map(languages => ({
            appStrings: languages.appStrings || {},
            appListStrings: languages.appListStrings || {}
        })));
    }
    /**
     * call logout
     */
    doLogout() {
        this.auth.logout();
    }
    static { this.ɵfac = function LogoutUiComponent_Factory(t) { return new (t || LogoutUiComponent)(i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LogoutUiComponent, selectors: [["scrm-logout-ui"]], decls: 2, vars: 3, consts: [[4, "ngIf"], [1, "dropdown-item", "global-links-sublink", 3, "click"]], template: function LogoutUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LogoutUiComponent_ng_container_0_Template, 3, 1, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoutUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-logout-ui', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <a class=\"dropdown-item global-links-sublink\"\n       (click)=\"doLogout()\">{{vm.appStrings[logout.logoutAction.label] || ''}}</a>\n</ng-container>\n<!-- this component should be used in navigation bar / bottom of user action menu -->\n" }]
    }], function () { return [{ type: AuthService }, { type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoutUiModule {
    static { this.ɵfac = function LogoutUiModule_Factory(t) { return new (t || LogoutUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LogoutUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoutUiModule, [{
        type: NgModule,
        args: [{
                declarations: [LogoutUiComponent],
                exports: [LogoutUiComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LogoutUiModule, { declarations: [LogoutUiComponent], imports: [CommonModule], exports: [LogoutUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function MessageUiComponent_div_0_div_1_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const message_r5 = i0.ɵɵnextContext().$implicit;
    const appStrings_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(appStrings_r1[message_r5.labelKey] || message_r5.labelKey || "");
} }
function MessageUiComponent_div_0_div_1_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const message_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(message_r5.text);
} }
function MessageUiComponent_div_0_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵlistener("click", function MessageUiComponent_div_0_div_1_div_1_Template_div_click_0_listener() { const restoredCtx = i0.ɵɵrestoreView(_r12); const message_r5 = restoredCtx.$implicit; const ctx_r11 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r11.close(message_r5)); });
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_div_1_ng_container_1_Template, 2, 1, "ng-container", 6);
    i0.ɵɵtemplate(2, MessageUiComponent_div_0_div_1_div_1_ng_container_2_Template, 2, 1, "ng-container", 6);
    i0.ɵɵelementStart(3, "a", 7);
    i0.ɵɵlistener("click", function MessageUiComponent_div_0_div_1_div_1_Template_a_click_3_listener() { const restoredCtx = i0.ɵɵrestoreView(_r12); const message_r5 = restoredCtx.$implicit; const ctx_r13 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r13.close(message_r5)); });
    i0.ɵɵelementStart(4, "span", 8);
    i0.ɵɵtext(5, "\u00D7");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const message_r5 = ctx.$implicit;
    i0.ɵɵclassMapInterpolate1("message ", message_r5.type, " alert-dismissible fade show shadow");
    i0.ɵɵproperty("@fade", undefined);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r5.labelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", message_r5.text && !message_r5.labelKey);
} }
function MessageUiComponent_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_div_1_Template, 6, 6, "div", 4);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const items_r3 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", items_r3);
} }
function MessageUiComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, MessageUiComponent_div_0_div_1_Template, 2, 1, "div", 2);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 1, ctx_r0.messages$));
} }
class MessageUiComponent {
    constructor(messageService, languages) {
        this.messageService = messageService;
        this.languages = languages;
        this.appStrings$ = languages.appStrings$;
    }
    ngOnInit() {
        this.messages$ = this.messageService.messages$;
    }
    close(message) {
        this.messageService.contains(message, true);
    }
    static { this.ɵfac = function MessageUiComponent_Factory(t) { return new (t || MessageUiComponent)(i0.ɵɵdirectiveInject(MessageService), i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MessageUiComponent, selectors: [["scrm-message-ui"]], decls: 2, vars: 3, consts: [["class", "container-fluid alert-fixed message-wrapper", 4, "ngIf"], [1, "container-fluid", "alert-fixed", "message-wrapper"], ["class", "d-flex justify-content-center flex-column align-items-center message-container", 4, "ngIf"], [1, "d-flex", "justify-content-center", "flex-column", "align-items-center", "message-container"], ["role", "alert", 3, "class", "click", 4, "ngFor", "ngForOf"], ["role", "alert", 3, "click"], [4, "ngIf"], ["type", "button", "data-dismiss", "alert", "aria-label", "Close", 1, "close", 3, "click"], ["aria-hidden", "true"]], template: function MessageUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MessageUiComponent_div_0_Template, 3, 3, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.appStrings$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, i2.AsyncPipe], encapsulation: 2, data: { animation: [
                trigger('fade', [
                    transition(':enter', useAnimation(fadeIn, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                    transition(':leave', useAnimation(fadeOut, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                ])
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-message-ui', animations: [
                    trigger('fade', [
                        transition(':enter', useAnimation(fadeIn, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                        transition(':leave', useAnimation(fadeOut, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                    ])
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"container-fluid alert-fixed message-wrapper\" *ngIf=\"(appStrings$ | async) as appStrings\">\n    <div class=\"d-flex justify-content-center flex-column align-items-center message-container\"\n         *ngIf=\"(messages$ | async) as items\">\n        <div *ngFor=\"let message of items\"\n             (click)=\"close(message)\"\n             class=\"message {{ message.type }} alert-dismissible fade show shadow\"\n             [@fade]\n             role=\"alert\">\n            <ng-container *ngIf=\"message.labelKey\">{{appStrings[message.labelKey] || message.labelKey || ''}}</ng-container>\n            <ng-container *ngIf=\"message.text && !message.labelKey\">{{message.text}}</ng-container>\n            <a (click)=\"close(message)\" type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">\n                <span aria-hidden=\"true\">&times;</span>\n            </a>\n        </div>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: MessageService }, { type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MessageUiModule {
    static { this.ɵfac = function MessageUiModule_Factory(t) { return new (t || MessageUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MessageUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageUiModule, [{
        type: NgModule,
        args: [{
                declarations: [MessageUiComponent],
                exports: [MessageUiComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MessageUiModule, { declarations: [MessageUiComponent], imports: [CommonModule], exports: [MessageUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ClassicModalModule {
    static { this.ɵfac = function ClassicModalModule_Factory(t) { return new (t || ClassicModalModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ClassicModalModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModalModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassicModalModule, [{
        type: NgModule,
        args: [{
                declarations: [ClassicModalComponent],
                imports: [
                    CommonModule,
                    ModalModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ClassicModalModule, { declarations: [ClassicModalComponent], imports: [CommonModule,
        ModalModule] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModalButtonGroupComponent {
    constructor(buttonUtils, config) {
        this.buttonUtils = buttonUtils;
        this.config = config;
        this.activeModal = null;
        this.defaultButtonGroup = {
            breakpoint: 4,
            wrapperKlass: ['modal-buttons'],
            buttonKlass: ['modal-button', 'btn', 'btn-sm'],
            buttons: []
        };
        const ui = this.config.getConfigValue('ui');
        if (ui && ui.modal_button_group_breakpoint) {
            this.defaultButtonGroup.breakpoint = ui.modal_buttons_collapse_breakpoint;
        }
    }
    ngOnInit() {
        if (this.config$) {
            this.buttonGroup$ = this.config$.pipe(map((config) => this.mapButtonGroup(config)));
        }
    }
    mapButtonGroup(config) {
        const group = defaults({ ...config }, deepClone(this.defaultButtonGroup));
        this.mapButtons(group);
        return group;
    }
    mapButtons(group) {
        const buttons = group.buttons || [];
        group.buttons = [];
        if (buttons.length > 0) {
            buttons.forEach(modalButton => {
                const button = this.buttonUtils.addOnClickPartial(modalButton, this.activeModal);
                group.buttons.push(button);
            });
        }
    }
    static { this.ɵfac = function ModalButtonGroupComponent_Factory(t) { return new (t || ModalButtonGroupComponent)(i0.ɵɵdirectiveInject(ButtonUtils), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ModalButtonGroupComponent, selectors: [["scrm-modal-button-group"]], inputs: { config$: "config$", activeModal: "activeModal" }, decls: 1, vars: 1, consts: [[3, "config$"]], template: function ModalButtonGroupComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "scrm-button-group", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("config$", ctx.buttonGroup$);
        } }, dependencies: [ButtonGroupComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModalButtonGroupComponent, [{
        type: Component,
        args: [{ selector: 'scrm-modal-button-group', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-button-group [config$]=\"buttonGroup$\"></scrm-button-group>\n" }]
    }], function () { return [{ type: ButtonUtils }, { type: SystemConfigStore }]; }, { config$: [{
            type: Input
        }], activeModal: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MessageModalComponent {
    constructor(activeModal) {
        this.activeModal = activeModal;
        this.buttons = [];
    }
    ngOnInit() {
        this.buttonGroup$ = of({
            buttons: this.buttons
        });
        this.closeButton = {
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            onClick: () => {
                this.activeModal.close({
                    type: 'close-button'
                });
            }
        };
    }
    static { this.ɵfac = function MessageModalComponent_Factory(t) { return new (t || MessageModalComponent)(i0.ɵɵdirectiveInject(i3$1.NgbActiveModal)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MessageModalComponent, selectors: [["scrm-message-modal"]], inputs: { titleKey: "titleKey", textKey: "textKey", buttons: "buttons" }, decls: 6, vars: 6, consts: [["klass", "message-modal", 3, "closable", "close", "title"], ["modal-body", "", 1, "p-3"], [3, "labelKey"], ["modal-footer", ""], [3, "activeModal", "config$"]], template: function MessageModalComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-modal", 0)(1, "div", 1)(2, "span");
            i0.ɵɵelement(3, "scrm-label", 2);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(4, "div", 3);
            i0.ɵɵelement(5, "scrm-modal-button-group", 4);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("closable", true)("close", ctx.closeButton)("title", ctx.titleKey || "");
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("labelKey", ctx.textKey);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("activeModal", ctx.activeModal)("config$", ctx.buttonGroup$);
        } }, dependencies: [ModalComponent, LabelComponent, ModalButtonGroupComponent], encapsulation: 2, data: { animation: [
                trigger('modalFade', [
                    transition('void <=> *', [
                        animate('800ms')
                    ]),
                ]),
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageModalComponent, [{
        type: Component,
        args: [{ selector: 'scrm-message-modal', animations: [
                    trigger('modalFade', [
                        transition('void <=> *', [
                            animate('800ms')
                        ]),
                    ]),
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-modal [closable]=\"true\"\n            [close]=\"closeButton\"\n            [title]=\"titleKey || ''\"\n            klass=\"message-modal\">\n\n    <div class=\"p-3\" modal-body>\n        <span><scrm-label [labelKey]=\"textKey\"></scrm-label></span>\n    </div>\n\n    <div modal-footer>\n        <scrm-modal-button-group [activeModal]=\"activeModal\"\n                                 [config$]=\"buttonGroup$\">\n        </scrm-modal-button-group>\n    </div>\n</scrm-modal>\n" }]
    }], function () { return [{ type: i3$1.NgbActiveModal }]; }, { titleKey: [{
            type: Input
        }], textKey: [{
            type: Input
        }], buttons: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModalButtonGroupModule {
    static { this.ɵfac = function ModalButtonGroupModule_Factory(t) { return new (t || ModalButtonGroupModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ModalButtonGroupModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonGroupModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModalButtonGroupModule, [{
        type: NgModule,
        args: [{
                declarations: [ModalButtonGroupComponent],
                exports: [
                    ModalButtonGroupComponent
                ],
                imports: [
                    CommonModule,
                    ButtonGroupModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ModalButtonGroupModule, { declarations: [ModalButtonGroupComponent], imports: [CommonModule,
        ButtonGroupModule], exports: [ModalButtonGroupComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MessageModalModule {
    static { this.ɵfac = function MessageModalModule_Factory(t) { return new (t || MessageModalModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: MessageModalModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModalModule,
            ButtonGroupModule,
            LabelModule,
            ModalButtonGroupModule,
            NgbModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MessageModalModule, [{
        type: NgModule,
        args: [{
                declarations: [MessageModalComponent],
                exports: [MessageModalComponent],
                imports: [
                    CommonModule,
                    ModalModule,
                    ButtonGroupModule,
                    LabelModule,
                    ModalButtonGroupModule,
                    NgbModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MessageModalModule, { declarations: [MessageModalComponent], imports: [CommonModule,
        ModalModule,
        ButtonGroupModule,
        LabelModule,
        ModalButtonGroupModule,
        NgbModule], exports: [MessageModalComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModuleTitleComponent {
    constructor() {
        this.title = '';
    }
    static { this.ɵfac = function ModuleTitleComponent_Factory(t) { return new (t || ModuleTitleComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ModuleTitleComponent, selectors: [["scrm-module-title"]], inputs: { title: "title" }, decls: 2, vars: 3, template: function ModuleTitleComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
            i0.ɵɵpipe(1, "uppercase");
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", i0.ɵɵpipeBind1(1, 1, ctx.title), "\n");
        } }, dependencies: [i2.UpperCasePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModuleTitleComponent, [{
        type: Component,
        args: [{ selector: 'scrm-module-title', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{title | uppercase}}\n" }]
    }], null, { title: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ModuleTitleModule {
    static { this.ɵfac = function ModuleTitleModule_Factory(t) { return new (t || ModuleTitleModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ModuleTitleModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModuleTitleModule, [{
        type: NgModule,
        args: [{
                declarations: [ModuleTitleComponent],
                exports: [ModuleTitleComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ModuleTitleModule, { declarations: [ModuleTitleComponent], imports: [CommonModule], exports: [ModuleTitleComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
var LinkTarget;
(function (LinkTarget) {
    LinkTarget["none"] = "";
    LinkTarget["blank"] = "_blank";
    LinkTarget["parent"] = "_parent";
    LinkTarget["self"] = "_self";
    LinkTarget["top"] = "_top";
})(LinkTarget || (LinkTarget = {}));

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LinkModel {
    constructor() {
        this.target = LinkTarget.none;
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NavbarAbstract {
    /**
     * Public API
     */
    constructor(routeConverter, moduleNavigation, preferences, language, appState, moduleNameMapper) {
        this.routeConverter = routeConverter;
        this.moduleNavigation = moduleNavigation;
        this.preferences = preferences;
        this.language = language;
        this.appState = appState;
        this.moduleNameMapper = moduleNameMapper;
        this.authenticated = true;
        this.logo = new LogoAbstract();
        this.useGroupTabs = false;
        this.globalActions = [];
        this.currentUser = {
            id: '',
            firstName: '',
            lastName: '',
        };
        this.all = {
            modules: [],
            extra: [],
        };
        this.menu = [];
    }
    /**
     * Reset menus
     */
    resetMenu() {
        this.menu = [];
        this.globalActions = [];
        this.all.modules = [];
        this.all.extra = [];
        this.current = null;
        this.currentUser = {};
    }
    /**
     * Build user action menu
     *
     * @param {[]} userActionMenu info
     * @param {object} currentUser info
     */
    buildUserActionMenu(userActionMenu, currentUser) {
        this.currentUser.id = currentUser.id;
        this.currentUser.firstName = currentUser.firstName;
        this.currentUser.lastName = currentUser.lastName;
        if (userActionMenu) {
            userActionMenu.forEach((subMenu) => {
                const name = subMenu.name;
                let url = subMenu.url;
                if (name === 'logout') {
                    return;
                }
                let target = LinkTarget.none;
                if (name === 'training') {
                    target = LinkTarget.blank;
                }
                else {
                    url = this.routeConverter.toFrontEndLink(url);
                }
                const label = this.language.getAppString(subMenu.labelKey) ?? '';
                this.globalActions.push({
                    link: {
                        url,
                        label,
                        target
                    },
                });
            });
        }
        return;
    }
    /**
     * Build navbar
     *
     * @param {object} navigation info
     * @param {object} currentUser info
     * @param {number} maxTabs to display
     */
    build(navigation, currentUser, maxTabs) {
        this.buildUserActionMenu(navigation.userActionMenu, currentUser);
        const navigationParadigm = this.preferences.getUserPreference('navigation_paradigm');
        const sort = this.preferences.getUserPreference('sort_modules_by_name') === 'on';
        if (navigationParadigm === 'm') {
            this.buildModuleNavigation(navigation, maxTabs, sort);
            return;
        }
        if (navigationParadigm === 'gm') {
            this.buildGroupedNavigation(navigation, maxTabs, sort);
            return;
        }
    }
    /**
     * Build Group tab menu
     *
     * @param {[]} items list
     * @param {object} modules info
     * @param {number} threshold limit
     * @param {object} groupedTabs info
     * @param {boolean} sort flag
     */
    buildGroupTabMenu(items, modules, threshold, groupedTabs, sort) {
        const navItems = [];
        const moreItems = [];
        if (items && items.length > 0) {
            items.forEach((module) => {
                moreItems.push(this.buildTabMenuItem(module, modules[module]));
            });
            if (sort) {
                this.sortMenuItems(moreItems);
            }
        }
        let count = 0;
        groupedTabs.forEach((groupedTab) => {
            if (count < threshold) {
                navItems.push(this.buildTabGroupedMenuItem(groupedTab.labelKey, groupedTab.modules, modules, sort));
            }
            count++;
        });
        this.menu = navItems;
        this.all.modules = moreItems;
    }
    /**
     *
     * Internal API
     *
     */
    /**
     * Build module navigation
     *
     * @param {object} navigation info
     * @param {number} maxTabs to use
     * @param {boolean} sort flag
     */
    buildModuleNavigation(navigation, maxTabs, sort) {
        if (!ready([navigation.tabs, navigation.modules])) {
            return;
        }
        this.buildTabMenu(navigation.tabs, navigation.modules, maxTabs, sort);
        this.buildSelectedModule(navigation);
    }
    /**
     * Build grouped navigation
     *
     * @param {object} navigation info
     * @param {number} maxTabs to use
     * @param {boolean} sort flag
     */
    buildGroupedNavigation(navigation, maxTabs, sort) {
        if (!ready([navigation.tabs, navigation.modules, navigation.groupedTabs])) {
            return;
        }
        this.buildGroupTabMenu(navigation.tabs, navigation.modules, maxTabs, navigation.groupedTabs, sort);
        this.buildSelectedModule(navigation);
    }
    /**
     * Build selected module
     *
     * @param {object} navigation info
     */
    buildSelectedModule(navigation) {
        const module = this.appState.getModule() ?? '';
        if (module === '' || module === 'home') {
            return;
        }
        if (!navigation.modules[module]) {
            return;
        }
        this.current = this.buildTabMenuItem(module, navigation.modules[module]);
    }
    /**
     * Build tab / module menu
     *
     * @param {[]} items list
     * @param {object} modules info
     * @param {number} threshold limit
     * @param {boolean} sort flag
     */
    buildTabMenu(items, modules, threshold, sort) {
        const navItems = [];
        const moreItems = [];
        if (!items || items.length === 0) {
            this.menu = navItems;
            this.all.modules = moreItems;
            return;
        }
        let count = 0;
        items.forEach((module) => {
            const item = this.buildTabMenuItem(module, modules[module]);
            if (module === 'home' || this.appState.getModule() === module || count > threshold) {
                moreItems.push(item);
            }
            else {
                navItems.push(item);
            }
            count++;
        });
        if (sort) {
            this.sortMenuItems(navItems);
            this.sortMenuItems(moreItems);
        }
        this.menu = navItems;
        this.all.modules = moreItems;
    }
    /**
     * Build Grouped Tab menu item
     *
     * @param {string} moduleLabel to display
     * @param {object} groupedModules list
     * @param {object} modules list
     * @param {boolean} sort flag
     *
     * @returns {object} group tab menu item
     */
    buildTabGroupedMenuItem(moduleLabel, groupedModules, modules, sort) {
        return {
            link: {
                label: this.language.getAppString(moduleLabel) || moduleLabel,
                url: '',
                route: null,
                params: null
            },
            icon: '',
            submenu: this.buildGroupedMenu(groupedModules, modules, sort)
        };
    }
    /**
     * Build Grouped menu
     *
     * @param {object} groupedModules info
     * @param {object} modules map
     * @param {boolean} sort flag
     *
     * @returns {[]} menu item array
     */
    buildGroupedMenu(groupedModules, modules, sort) {
        const groupedItems = [];
        let homeMenuItem = null;
        groupedModules.forEach((groupedModule) => {
            const module = modules[groupedModule];
            if (!module) {
                return;
            }
            const moduleMenuItem = this.buildTabMenuItem(groupedModule, module);
            if (groupedModule === 'home') {
                homeMenuItem = moduleMenuItem;
                return;
            }
            groupedItems.push(moduleMenuItem);
        });
        if (sort) {
            this.sortMenuItems(groupedItems);
        }
        if (homeMenuItem) {
            groupedItems.unshift(homeMenuItem);
        }
        return groupedItems;
    }
    /**
     * Build module menu items
     *
     * @param {string} module name
     * @param {object} moduleInfo info
     *
     * @returns {object} menuItem
     */
    buildTabMenuItem(module, moduleInfo) {
        if (moduleInfo.name) {
            module = moduleInfo.name;
        }
        const moduleRoute = this.moduleNavigation.getModuleRoute(moduleInfo);
        const appListStrings = this.language.getLanguageStrings()?.appListStrings ?? {};
        const menuItem = {
            link: {
                label: this.moduleNavigation.getModuleLabel(moduleInfo, appListStrings),
                url: moduleRoute.url,
                route: moduleRoute.route,
                params: null
            },
            icon: this.moduleNameMapper.toLegacy(module) ?? null,
            submenu: [],
            module: module ?? null,
            isGroupedMenu: false
        };
        let hasSubmenu = false;
        if (moduleInfo) {
            moduleInfo.menu.forEach((subMenu) => {
                const sublinks = subMenu.sublinks || [];
                const subMenuItem = this.buildSubMenuItem(module, subMenu, sublinks);
                menuItem.submenu.push(subMenuItem);
                if (sublinks.length > 0) {
                    hasSubmenu = true;
                }
            });
        }
        menuItem.isGroupedMenu = hasSubmenu;
        return menuItem;
    }
    buildSubMenuItem(module, subMenu, sublinks) {
        const moduleActionRoute = this.moduleNavigation.getActionRoute(subMenu);
        const subMenuItem = {
            link: {
                label: this.moduleNavigation.getActionLabel(module, subMenu, this.language.getLanguageStrings()),
                url: moduleActionRoute.url,
                route: moduleActionRoute.route,
                params: moduleActionRoute.params,
                process: moduleActionRoute.process
            },
            icon: subMenu.icon || '',
            submenu: sublinks.map((item) => this.buildSubMenuItem(module, item, [])),
        };
        return subMenuItem;
    }
    /**
     * Sort menu items by label
     *
     * @param {object} navItems to sort
     */
    sortMenuItems(navItems) {
        navItems.sort((a, b) => {
            const nameA = a.link.label.toUpperCase(); // ignore upper and lowercase
            const nameB = b.link.label.toUpperCase(); // ignore upper and lowercase
            if (nameA < nameB) {
                return -1;
            }
            if (nameA > nameB) {
                return 1;
            }
            // names must be equal
            return 0;
        });
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const ROUTE_PREFIX = './#';
class RouteConverter {
    constructor(moduleNameMapper, actionNameMapper, systemConfigStore) {
        this.moduleNameMapper = moduleNameMapper;
        this.actionNameMapper = actionNameMapper;
        this.systemConfigStore = systemConfigStore;
    }
    /**
     * Public Api
     */
    /**
     * Converts legacyLink to front end link. Includes the /#/.
     *
     * @param {string} legacyLink legacy url
     * @returns {string} frontend path
     */
    toFrontEndLink(legacyLink) {
        return '#/' + this.toFrontEndRoute(legacyLink);
    }
    /**
     * Converts legacyLink to front end route
     *
     * @param {string} legacyLink legacy url
     * @returns {string} frontend path
     */
    toFrontEndRoute(legacyLink) {
        if (legacyLink && legacyLink.includes('/#/')) {
            const anchorParts = legacyLink.split('/#/');
            if (anchorParts.length < 2) {
                return '/';
            }
            return anchorParts[1];
        }
        const info = this.parse(legacyLink);
        if (!info) {
            return '/';
        }
        let route = this.buildRoute(info.module, info.action, info.record);
        route += this.buildQueryString(info.params, ['module', 'action', 'record']);
        return route;
    }
    /**
     * Build legacy link from router information
     *
     * @param {object} params route params
     * @param {object} queryParams route query params
     * @returns {string} legacy url
     */
    toLegacy(params, queryParams) {
        let path = './legacy/index.php';
        const queryObject = {
            ...queryParams,
        };
        if (params.module) {
            queryObject.module = this.moduleNameMapper.toLegacy(params.module);
        }
        if (params.action) {
            queryObject.action = this.actionNameMapper.toLegacy(params.action);
        }
        if (params.record) {
            queryObject.record = params.record;
        }
        path += this.buildQueryString(queryObject);
        return path;
    }
    /**
     * Parse legacy link
     *
     * @param {string} legacyLink to parse
     * @returns {object} route info
     */
    parse(legacyLink) {
        const parser = new DefaultUrlSerializer();
        const replacedString = legacyLink.replace('/legacy', '');
        const parts = replacedString.split('?');
        if (parts.length < 2) {
            return null;
        }
        const tree = parser.parse('/?' + parts[1]);
        const params = tree.queryParamMap;
        const module = params.get('module') || '';
        const action = params.get('action') || '';
        const record = params.get('record') || '';
        return {
            module,
            action,
            record,
            params: tree.queryParams
        };
    }
    /**
     * Map route url to RouteInfo
     *
     * @returns {object} RouteInfo of the current URL
     * @description Parses route information from ActivatedRouteSnapshot to RouteInfo object
     * @param {UrlSegment[]} urlSegment from the Router object
     */
    parseRouteURL(urlSegment) {
        return {
            module: urlSegment[0]?.path ?? '',
            action: urlSegment[1]?.path ?? 'index',
            record: urlSegment[2]?.path ?? ''
        };
    }
    /**
     * check if the current route is a classic view route
     *
     * @returns {object} RouteInfo
     * @description if the current url is a classic view url; so redirect back to the same view
     * @param {UrlTree} urlTree of current route
     */
    parseRouteInfoFromUrlTree(urlTree) {
        const urlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
        const urlSegment = urlSegmentGroup.segments;
        return this.parseRouteURL(urlSegment);
    }
    /**
     * check if the current route is a classic view route
     *
     * @returns {boolean} true/false
     * @param {UrlTree} urlTree of the route
     * @description if the current url is a classic view url; so redirect back to the same view
     */
    isClassicViewRoute(urlTree) {
        const configRoutes = this.systemConfigStore.getConfigValue('module_routing');
        const currentRouteInfo = this.parseRouteInfoFromUrlTree(urlTree);
        const module = currentRouteInfo.module;
        const action = currentRouteInfo.action;
        return !configRoutes[module] || !configRoutes[module][action];
    }
    /**
     * Check if given routeInfo matches the provided activated route
     *
     * @param {object} route to check
     * @param {object} routeInfo to check
     * @returns {boolean} is match
     */
    matchesActiveRoute(route, routeInfo) {
        const toCheck = [
            {
                name: 'module',
                map: (value) => {
                    if (!value) {
                        return value;
                    }
                    return this.mapModuleToFrontend(value);
                }
            },
            {
                name: 'action',
                map: (value) => {
                    if (!value) {
                        return value;
                    }
                    return this.mapActionToFrontEnd(value);
                }
            },
            {
                name: 'record',
                map: (value) => value
            }
        ];
        let match = true;
        toCheck.forEach((param) => {
            if (!route.snapshot.params[param.name] && !routeInfo[param.name]) {
                return;
            }
            match = match && (route.snapshot.params[param.name] === param.map(routeInfo[param.name]));
        });
        return match;
    }
    /**
     * Internal API
     */
    /**
     * Build front end route
     *
     * @param {string} module name
     * @param {string} action name
     * @param {string} record id
     * @returns {string} route
     */
    buildRoute(module, action, record) {
        const moduleName = this.mapModuleToFrontend(module);
        let route = `${moduleName}`;
        if (action) {
            const actionName = this.mapActionToFrontEnd(action);
            route += `/${actionName}`;
        }
        if (record) {
            route += `/${record}`;
        }
        return route;
    }
    /**
     * Build query string
     *
     * @param {object} queryParams query parameters
     * @param {string[]} exclude parameters to exclude
     * @returns {string} query string
     */
    buildQueryString(queryParams, exclude = []) {
        let params = new HttpParams();
        Object.keys(queryParams).forEach((param) => {
            if (exclude.includes(param)) {
                return;
            }
            const value = queryParams[param];
            params = params.set(param, value);
        });
        if (params.keys().length > 0) {
            return '?' + params.toString();
        }
        return '';
    }
    /**
     * Map legacy module name to frontend
     *
     * @param {string} module legacy name
     * @returns {string} frontend name
     */
    mapModuleToFrontend(module) {
        return this.moduleNameMapper.toFrontend(module);
    }
    /**
     * Map legacy action name to frontend
     *
     * @param {string} action legacy name
     * @returns {string} frontend name
     */
    mapActionToFrontEnd(action) {
        return this.actionNameMapper.toFrontend(action);
    }
    static { this.ɵfac = function RouteConverter_Factory(t) { return new (t || RouteConverter)(i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(ActionNameMapper), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RouteConverter, factory: RouteConverter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RouteConverter, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: ModuleNameMapper }, { type: ActionNameMapper }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GlobalSearch {
    constructor(router) {
        this.router = router;
    }
    /**
     * Public Api
     */
    /**
     * Navigate to global search
     *
     * @param {string} searchTerm to search
     * @returns {object} Promise<boolean>
     */
    navigateToSearch(searchTerm, searchController) {
        let route = '/home/search';
        if (searchController === 'UnifiedSearch') {
            route = '/home/unified-search';
        }
        let queryString = '';
        if (searchTerm) {
            queryString = searchTerm;
        }
        return this.router.navigate([route], {
            queryParams: {
                // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
                query_string: queryString
            }
        });
    }
    static { this.ɵfac = function GlobalSearch_Factory(t) { return new (t || GlobalSearch)(i0.ɵɵinject(i1$2.Router)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GlobalSearch, factory: GlobalSearch.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GlobalSearch, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: i1$2.Router }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$t = ["searchInput"];
const _c1$6 = function (a0) { return { "dropdown-active": a0 }; };
function SearchBarComponent_ng_container_0_ul_5_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ul", 9)(1, "li", 10)(2, "a", 11);
    i0.ɵɵlistener("click", function SearchBarComponent_ng_container_0_ul_5_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r6.searchWithEnter()); });
    i0.ɵɵelement(3, "scrm-image", 12);
    i0.ɵɵelementStart(4, "span", 13);
    i0.ɵɵtext(5, "\"");
    i0.ɵɵelementStart(6, "strong");
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd();
    i0.ɵɵtext(8);
    i0.ɵɵpipe(9, "lowercase");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(5, _c1$6, ctx_r3.searchWord));
    i0.ɵɵadvance(6);
    i0.ɵɵtextInterpolate(ctx_r3.searchWord);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1("\" ", i0.ɵɵpipeBind1(9, 3, vm_r1.appStrings["LBL_IN_EVERYWHERE"]), "");
} }
function SearchBarComponent_ng_container_0_button_7_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 14);
    i0.ɵɵlistener("click", function SearchBarComponent_ng_container_0_button_7_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.searchWithEnter()); });
    i0.ɵɵelement(1, "scrm-image", 12);
    i0.ɵɵelementEnd();
} }
function SearchBarComponent_ng_container_0_button_8_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 15);
    i0.ɵɵlistener("click", function SearchBarComponent_ng_container_0_button_8_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r11.clearSearchTerm()); });
    i0.ɵɵelement(1, "scrm-image", 16);
    i0.ɵɵelementEnd();
} }
const _c2$1 = function (a0) { return { "search-focused": a0 }; };
function SearchBarComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "form", 1)(2, "div", 2)(3, "input", 3, 4);
    i0.ɵɵlistener("focus", function SearchBarComponent_ng_container_0_Template_input_focus_3_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r13.onFocus()); })("blur", function SearchBarComponent_ng_container_0_Template_input_blur_3_listener() { i0.ɵɵrestoreView(_r14); const ctx_r15 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r15.onBlur()); })("keydown.enter", function SearchBarComponent_ng_container_0_Template_input_keydown_enter_3_listener() { i0.ɵɵrestoreView(_r14); const ctx_r16 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r16.searchTrigger === "enter" ? ctx_r16.searchWithEnter() : null); })("input", function SearchBarComponent_ng_container_0_Template_input_input_3_listener() { i0.ɵɵrestoreView(_r14); const _r2 = i0.ɵɵreference(4); const ctx_r17 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r17.searchTrigger === "input" ? ctx_r17.searchWithInput(_r2.value) : null); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, SearchBarComponent_ng_container_0_ul_5_Template, 10, 7, "ul", 5);
    i0.ɵɵelementStart(6, "div", 6);
    i0.ɵɵtemplate(7, SearchBarComponent_ng_container_0_button_7_Template, 2, 0, "button", 7);
    i0.ɵɵtemplate(8, SearchBarComponent_ng_container_0_button_8_Template, 2, 0, "button", 8);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r0.klass)("formGroup", ctx_r0.searchForm);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(7, _c2$1, ctx_r0.isFocused));
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate1("placeholder", "", vm_r1.appStrings[ctx_r0.labelKey] || "", "...");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.searchWord.length && ctx_r0.hasSearchTyped && ctx_r0.searchTrigger === "enter");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !ctx_r0.hasSearchTyped);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.hasSearchTyped);
} }
class SearchBarComponent {
    constructor(languageStore) {
        this.languageStore = languageStore;
        this.labelKey = '';
        this.klass = '';
        this.isMobile = false;
        this.searchTrigger = 'enter';
        this.isSearchVisible = new EventEmitter(false);
        this.searchExpression = new EventEmitter();
        this.searchWord = '';
        this.isFocused = false;
        this.hasSearchTyped = false;
        this.subs = [];
        this.languages$ = this.languageStore.vm$;
        this.vm$ = this.languages$.pipe(map(language => {
            return {
                appStrings: language.appStrings || {}
            };
        }));
    }
    ngOnInit() {
        this.searchForm = new FormGroup({
            searchTerm: new FormControl('')
        });
        this.subs.push(this.searchForm.get('searchTerm').valueChanges
            .pipe(tap(data => {
            if (data) {
                this.hasSearchTyped = true;
            }
            else {
                this.hasSearchTyped = false;
            }
        }), distinctUntilChanged(), filter(searchString => searchString?.length > 1)).subscribe((term) => this.searchWord = term));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    searchWithEnter() {
        if (this.searchWord.length) {
            this.searchExpression.emit(this.searchWord);
            this.clearSearchTerm();
            this.searchInput.nativeElement.blur();
        }
        else {
            if (this.isMobile) {
                this.onBlur();
            }
        }
    }
    searchWithInput(value) {
        this.searchExpression.emit(value);
    }
    clearSearchTerm() {
        this.searchForm.reset();
        this.hasSearchTyped = false;
        this.searchWord = '';
        if (this.searchTrigger === 'input') {
            this.searchWithInput(this.searchWord);
        }
    }
    onFocus() {
        this.isFocused = true;
        const initialValue = this.searchForm?.get('searchTerm')?.value ?? '';
        if (initialValue.length > 2) {
            this.hasSearchTyped = true;
            this.searchWord = initialValue;
        }
    }
    onBlur() {
        setTimeout(() => {
            this.isFocused = false;
            this.hasSearchTyped = false;
        }, 200);
        if (this.isMobile) {
            setTimeout(() => {
                this.isSearchVisible.emit(false);
            }, 50);
        }
    }
    static { this.ɵfac = function SearchBarComponent_Factory(t) { return new (t || SearchBarComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SearchBarComponent, selectors: [["scrm-search-bar"]], viewQuery: function SearchBarComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$t, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.searchInput = _t.first);
        } }, inputs: { labelKey: "labelKey", klass: "klass", isMobile: "isMobile", searchTrigger: "searchTrigger" }, outputs: { isSearchVisible: "isSearchVisible", searchExpression: "searchExpression" }, decls: 2, vars: 3, consts: [[4, "ngIf"], ["name", "search-bar", 1, "search-bar", 3, "ngClass", "formGroup"], [1, "input-group", "dropdown", 3, "ngClass"], ["formControlName", "searchTerm", "type", "text", "name", "search-bar-term", "aria-label", "Search", "data-toggle", "dropdown", "autocomplete", "off", "required", "", 1, "form-control", "dropdown-toggle", "search-bar-term", 3, "placeholder", "focus", "blur", "keydown.enter", "input"], ["searchInput", ""], ["class", "dropdown-menu global-search-dropdown", 4, "ngIf"], [1, "input-group-append"], ["class", "btn btn-default search-button d-flex align-items-center", "aria-label", "Search", "scrm-button-loading", "", 3, "click", 4, "ngIf"], ["class", "btn btn-default search-button d-flex align-items-center", "aria-label", "Close Search", "scrm-button-loading", "", 3, "click", 4, "ngIf"], [1, "dropdown-menu", "global-search-dropdown"], [1, "dropdown-item-block", 3, "ngClass"], [1, "dropdown-item", 3, "click"], ["image", "search", 1, "search-icon", "sicon"], [1, "dropdown-text", "ml-2"], ["aria-label", "Search", "scrm-button-loading", "", 1, "btn", "btn-default", "search-button", "d-flex", "align-items-center", 3, "click"], ["aria-label", "Close Search", "scrm-button-loading", "", 1, "btn", "btn-default", "search-button", "d-flex", "align-items-center", 3, "click"], ["image", "cross", 1, "search-icon", "sicon"]], template: function SearchBarComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SearchBarComponent_ng_container_0_Template, 9, 9, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgClass, i2.NgIf, i5$1.ɵNgNoValidate, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgControlStatusGroup, i5$1.RequiredValidator, ImageComponent, i5$1.FormGroupDirective, i5$1.FormControlName, i2.AsyncPipe, i2.LowerCasePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SearchBarComponent, [{
        type: Component,
        args: [{ selector: 'scrm-search-bar', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <form name=\"search-bar\" class=\"search-bar\" [ngClass]=\"klass\" [formGroup]=\"searchForm\">\n        <div class=\"input-group dropdown\" [ngClass]=\"{'search-focused': isFocused}\">\n            <input\n                formControlName=\"searchTerm\"\n                type=\"text\"\n                name=\"search-bar-term\"\n                class=\"form-control dropdown-toggle search-bar-term\"\n                placeholder=\"{{vm.appStrings[labelKey] || ''}}...\"\n                aria-label=\"Search\"\n                (focus)=\"onFocus()\"\n                (blur)=\"onBlur()\"\n                (keydown.enter)=\"searchTrigger === 'enter' ? searchWithEnter() : null\"\n                (input)=\"searchTrigger === 'input' ? searchWithInput(searchInput.value) : null\"\n                data-toggle=\"dropdown\"\n                autocomplete=\"off\"\n                #searchInput\n                required>\n            <ul class=\"dropdown-menu global-search-dropdown\" *ngIf=\"searchWord.length && hasSearchTyped && (searchTrigger === 'enter')\">\n                <li class=\"dropdown-item-block\" [ngClass]=\"{'dropdown-active': searchWord}\">\n                    <a class=\"dropdown-item\" (click)=\"searchWithEnter()\">\n                        <scrm-image class=\"search-icon sicon\" image=\"search\"></scrm-image>\n                        <span class=\"dropdown-text ml-2\">\"<strong>{{searchWord}}</strong>\" {{vm.appStrings['LBL_IN_EVERYWHERE'] | lowercase}}</span>\n                    </a>\n                </li>\n            </ul>\n\n            <div class=\"input-group-append\">\n                <button *ngIf=\"!hasSearchTyped\" class=\"btn btn-default search-button d-flex align-items-center\"\n                        aria-label=\"Search\"\n                        scrm-button-loading\n                        (click)=\"searchWithEnter()\">\n                    <scrm-image class=\"search-icon sicon\" image=\"search\"></scrm-image>\n                </button>\n\n                <button *ngIf=\"hasSearchTyped\" class=\"btn btn-default search-button d-flex align-items-center\"\n                        aria-label=\"Close Search\"\n                        scrm-button-loading\n                        (click)=\"clearSearchTerm()\">\n                    <scrm-image class=\"search-icon sicon\" image=\"cross\"></scrm-image>\n                </button>\n\n            </div>\n        </div>\n    </form>\n</ng-container>\n\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { searchInput: [{
            type: ViewChild,
            args: ['searchInput']
        }], labelKey: [{
            type: Input
        }], klass: [{
            type: Input
        }], isMobile: [{
            type: Input
        }], searchTrigger: [{
            type: Input
        }], isSearchVisible: [{
            type: Output
        }], searchExpression: [{
            type: Output
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ConfirmationModalService {
    constructor(modalService) {
        this.modalService = modalService;
    }
    showModal(messageLabel, onProceed) {
        const modal = this.modalService.open(MessageModalComponent);
        modal.componentInstance.textKey = messageLabel ?? 'LBL_GENERIC_CONFIRMATION';
        modal.componentInstance.buttons = [
            {
                labelKey: 'LBL_CANCEL',
                klass: ['btn-secondary'],
                onClick: activeModal => activeModal.dismiss()
            },
            {
                labelKey: 'LBL_PROCEED',
                klass: ['btn-main'],
                onClick: activeModal => {
                    onProceed();
                    activeModal.close();
                }
            },
        ];
    }
    static { this.ɵfac = function ConfirmationModalService_Factory(t) { return new (t || ConfirmationModalService)(i0.ɵɵinject(i3$1.NgbModal)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ConfirmationModalService, factory: ConfirmationModalService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfirmationModalService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: i3$1.NgbModal }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SelectModalService {
    constructor(languageStore, message, modalService) {
        this.languageStore = languageStore;
        this.message = message;
        this.modalService = modalService;
    }
    /**
     * Get Selected Record
     *
     * @param {string} selectModule: The Modal module
     * @param onSelectCallback
     * @returns {void}
     */
    showSelectModal(selectModule, onSelectCallback = null) {
        const modal = this.modalService.open(RecordListModalComponent, { size: 'xl', scrollable: true });
        modal.componentInstance.module = selectModule;
        modal.result.then((result) => {
            if (!result || !result.selection || !result.selection.selected) {
                return;
            }
            const record = this.getSelectedRecord(result);
            if (!record.id) {
                let message = this.languageStore.getFieldLabel('ERROR_NO_RECORD');
                this.message.addDangerMessage(message);
                return;
            }
            if (onSelectCallback !== null) {
                onSelectCallback(record);
            }
        });
    }
    /**
     * Get Selected Record
     *
     * @param {object} data RecordListModalResult
     * @returns {object} Record
     */
    getSelectedRecord(data) {
        let id = '';
        Object.keys(data.selection.selected).some(selected => {
            id = selected;
            return true;
        });
        let record = null;
        data.records.some(rec => {
            if (rec && rec.id === id) {
                record = rec;
                return true;
            }
        });
        return record;
    }
    static { this.ɵfac = function SelectModalService_Factory(t) { return new (t || SelectModalService)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(i3$1.NgbModal)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SelectModalService, factory: SelectModalService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SelectModalService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: LanguageStore }, { type: MessageService }, { type: i3$1.NgbModal }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseActionsAdapter {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.defaultActions = {
            detail: [],
            list: [],
            edit: [],
            create: [],
            massupdate: []
        };
    }
    /**
     * Run the action using given context
     * @param action
     * @param context
     */
    runAction(action, context = null) {
        const params = (action && action.params) || {};
        const displayConfirmation = params.displayConfirmation || false;
        const confirmationLabel = params.confirmationLabel || '';
        const selectModal = action.params && action.params.selectModal;
        const selectModule = selectModal && selectModal.module;
        if (displayConfirmation) {
            this.confirmation.showModal(confirmationLabel, () => {
                if (!selectModule) {
                    this.callAction(action, context);
                    return;
                }
                this.showSelectModal(selectModal.module, action, context);
            });
            return;
        }
        if (!selectModule) {
            this.callAction(action, context);
            return;
        }
        this.showSelectModal(selectModal.module, action, context);
    }
    /**
     * Run async buk action
     *
     * @returns void
     * @param {string} selectModule: module for which records are listed in Select Modal/Popup
     * @param {string} asyncAction: bulk action name
     * @param {ActionContext} context
     */
    showSelectModal(selectModule, asyncAction, context = null) {
        this.selectModalService.showSelectModal(selectModule, (modalRecord) => {
            if (modalRecord) {
                const { fields, formGroup, ...baseRecord } = modalRecord;
                asyncAction.params.modalRecord = baseRecord;
            }
            this.callAction(asyncAction, context);
        });
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `${action.key}`;
    }
    /**
     * Parse mode actions
     * @param declaredActions
     * @param mode
     * @param context
     */
    parseModeActions(declaredActions, mode, context = null) {
        if (!declaredActions) {
            return [];
        }
        const availableActions = {
            list: [],
            detail: [],
            edit: [],
            create: [],
            massupdate: [],
        };
        if (declaredActions && declaredActions.length) {
            declaredActions.forEach(action => {
                if (!action.modes || !action.modes.length) {
                    return;
                }
                action.modes.forEach(actionMode => {
                    if (!availableActions[actionMode] && !action.asyncProcess) {
                        return;
                    }
                    availableActions[actionMode].push(action);
                });
            });
        }
        availableActions.detail = availableActions.detail.concat(this.defaultActions.detail ?? []);
        availableActions.list = availableActions.list.concat(this.defaultActions.list ?? []);
        availableActions.edit = availableActions.edit.concat(this.defaultActions.edit ?? []);
        availableActions.create = availableActions.create.concat(this.defaultActions.create ?? []);
        availableActions.massupdate = availableActions.massupdate.concat(this.defaultActions.massupdate ?? []);
        const actions = [];
        availableActions[mode].forEach(action => {
            const actionHandler = this.actionManager.getHandler(action, mode);
            if (actionHandler) {
                const data = this.buildActionData(action, context);
                if (!this.shouldDisplay(actionHandler, data)) {
                    return;
                }
                action.status = actionHandler.getStatus(data) || '';
            }
            if (!actionHandler && !action?.asyncProcess) {
                return;
            }
            const module = (context && context.module) || '';
            const label = this.language.getFieldLabel(action.labelKey, module);
            actions.push({
                ...action,
                label
            });
        });
        return actions;
    }
    shouldDisplay(actionHandler, data) {
        return actionHandler && actionHandler.shouldDisplay(data);
    }
    /**
     * Call actions
     * @param action
     * @param context
     */
    callAction(action, context = null) {
        if (action.asyncProcess) {
            this.runAsyncAction(action, context);
            return;
        }
        this.runFrontEndAction(action, context);
    }
    /**
     * Run async actions
     * @param action
     * @param context
     */
    runAsyncAction(action, context = null) {
        const actionName = this.getActionName(action);
        const moduleName = this.getModuleName(context);
        this.message.removeMessages();
        const asyncData = this.buildActionInput(action, actionName, moduleName, context);
        this.asyncActionService.run(actionName, asyncData).pipe(take(1)).subscribe((process) => {
            this.afterAsyncAction(actionName, moduleName, asyncData, process, action, context);
        });
    }
    /**
     * Run after async action handlers
     * @param actionName
     * @param moduleName
     * @param asyncData
     * @param process
     * @param action
     * @param context
     * @protected
     */
    afterAsyncAction(actionName, moduleName, asyncData, process, action, context) {
        if (this.shouldReload(process)) {
            this.reload(action, process, context);
        }
        this.reloadMetadata(moduleName, action, process, context);
    }
    /**
     * Reload the metadata for the module
     * @param moduleName
     * @param action
     * @param process
     * @param context
     * @protected
     */
    reloadMetadata(moduleName, action, process, context) {
        const typesToLoad = [];
        if (this.shouldReloadRecentlyViewed(process)) {
            typesToLoad.push(this.metadata.typeKeys.recentlyViewed);
        }
        if (this.shouldReloadFavorites(process)) {
            typesToLoad.push(this.metadata.typeKeys.favorites);
        }
        if (typesToLoad && typesToLoad.length) {
            this.metadata.reloadModuleMetadata(moduleName, typesToLoad, false).pipe(take(1)).subscribe();
            if (typesToLoad.includes(this.metadata.typeKeys.recentlyViewed)) {
                this.appMetadataStore.load(moduleName, ['globalRecentlyViewed'], false).pipe(take(1)).subscribe();
            }
        }
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReloadRecentlyViewed(process) {
        return !!(process.data && process.data.reloadRecentlyViewed);
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReloadFavorites(process) {
        return !!(process.data && process.data.reloadFavorites);
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReload(process) {
        return !!(process.data && process.data.reload);
    }
    /**
     * Run front end action
     * @param action
     * @param context
     */
    runFrontEndAction(action, context = null) {
        const data = this.buildActionData(action, context);
        this.actionManager.run(action, this.getMode(), data);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseRecordActionsAdapter extends BaseActionsAdapter {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `record-${action.key}`;
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        return {
            action: actionName,
            module: moduleName,
            id: (context && context.record && context.record.id) || '',
            params: (action && action.params) || [],
        };
    }
    static { this.ɵfac = function BaseRecordActionsAdapter_Factory(t) { i0.ɵɵinvalidFactory(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseRecordActionsAdapter, factory: BaseRecordActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseRecordActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: undefined }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadListActionHandler extends ActionHandler {
    checkRecordAccess(data, defaultAcls = []) {
        return true;
    }
    /**
     * Navigate back
     * @param navigation
     * @param params
     * @param id
     * @param moduleName
     * @param record
     */
    navigateBack(navigation, params, id, moduleName, record) {
        let returnModule = navigation.getReturnModule(params);
        let returnAction = navigation.getReturnAction(params);
        let returnId = navigation.getReturnId(params);
        if (id === returnId) {
            return;
        }
        if (returnModule === moduleName &&
            returnAction === 'record' &&
            returnId !== id) {
            return;
        }
        if (!returnModule || !returnAction) {
            return;
        }
        navigation.navigateBack(record, moduleName, params);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessRecordThreadListAction extends RecordThreadListActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        const defaultAcls = data?.action?.acl ?? [];
        if (!defaultAcls.length) {
            return true;
        }
        return this.checkRecordAccess(data, defaultAcls);
    }
    static { this.ɵfac = function AsyncProcessRecordThreadListAction_Factory(t) { return new (t || AsyncProcessRecordThreadListAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessRecordThreadListAction, factory: AsyncProcessRecordThreadListAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessRecordThreadListAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadListActionManager extends BaseActionManager {
    constructor(async) {
        super();
        this.async = async;
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
    }
    static { this.ɵfac = function RecordThreadListActionManager_Factory(t) { return new (t || RecordThreadListActionManager)(i0.ɵɵinject(AsyncProcessRecordThreadListAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadListActionManager, factory: RecordThreadListActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadListActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AsyncProcessRecordThreadListAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadListActionsAdapter extends BaseRecordActionsAdapter {
    constructor(threadStore, language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.threadStore = threadStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.defaultActions = {
            detail: [],
            edit: [],
            create: [],
            list: []
        };
        this.collapseButtons = false;
    }
    getActions(context) {
        return of(this.threadStore.getListMetadata()).pipe(combineLatestWith(of('list')), map(([meta, mode]) => {
            if (!mode || !meta) {
                return [];
            }
            return this.parseModeActions(meta.actions, mode, this.threadStore.getViewContext());
        }));
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `record-thread-list-${action.key}`;
    }
    buildActionData(action, context) {
        return {
            threadStore: this.threadStore,
            action: action
        };
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        this.message.removeMessages();
        return {
            action: actionName,
            module: this.threadStore.module,
            ids: this.threadStore.getRecordIds(),
            params: (action && action.params) || []
        };
    }
    getMode() {
        return 'list';
    }
    getModuleName(context) {
        return this.threadStore.module;
    }
    reload(action, process, context) {
        const reloadThread = process?.data?.reloadThread ?? false;
        if (isTrue(reloadThread)) {
            this.threadStore.reload();
        }
    }
    /**
     * @inheritDoc
     */
    shouldReload(process) {
        const reloadThread = process?.data?.reloadThread ?? false;
        return isTrue(reloadThread);
    }
    static { this.ɵfac = function RecordThreadListActionsAdapter_Factory(t) { return new (t || RecordThreadListActionsAdapter)(i0.ɵɵinject(RecordThreadStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordThreadListActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadListActionsAdapter, factory: RecordThreadListActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadListActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordThreadStore }, { type: LanguageStore }, { type: RecordThreadListActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadListActionsAdapterFactory {
    constructor(language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(threadStore, config) {
        const adapter = new RecordThreadListActionsAdapter(threadStore, this.language, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.selectModalService, this.metadata, this.appMetadataStore);
        const collapseButtons = config?.collapseListActions ?? null;
        if (collapseButtons !== null) {
            adapter.collapseButtons = collapseButtons;
        }
        return adapter;
    }
    static { this.ɵfac = function RecordThreadListActionsAdapterFactory_Factory(t) { return new (t || RecordThreadListActionsAdapterFactory)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordThreadListActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadListActionsAdapterFactory, factory: RecordThreadListActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadListActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LanguageStore }, { type: RecordThreadListActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemActionHandler extends ActionHandler {
    checkRecordAccess(data, defaultAcls = []) {
        const record = data.itemStore.recordStore.getBaseRecord();
        const acls = record.acls ?? [];
        if (!acls || !acls.length) {
            return false;
        }
        const action = data.action ?? null;
        return this.checkAccess(action, acls, defaultAcls);
    }
    /**
     * Navigate back
     * @param navigation
     * @param params
     * @param id
     * @param moduleName
     * @param record
     */
    navigateBack(navigation, params, id, moduleName, record) {
        let returnModule = navigation.getReturnModule(params);
        let returnAction = navigation.getReturnAction(params);
        let returnId = navigation.getReturnId(params);
        if (id === returnId) {
            return;
        }
        if (returnModule === moduleName &&
            returnAction === 'record' &&
            returnId !== id) {
            return;
        }
        if (!returnModule || !returnAction) {
            return;
        }
        navigation.navigateBack(record, moduleName, params);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessRecordThreadItemAction extends RecordThreadItemActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        const defaultAcls = data?.action?.acl ?? [];
        if (!defaultAcls.length) {
            return true;
        }
        return this.checkRecordAccess(data, defaultAcls);
    }
    static { this.ɵfac = function AsyncProcessRecordThreadItemAction_Factory(t) { return new (t || AsyncProcessRecordThreadItemAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessRecordThreadItemAction, factory: AsyncProcessRecordThreadItemAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessRecordThreadItemAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemCancelAction extends RecordThreadItemActionHandler {
    constructor(modalService, navigation) {
        super();
        this.modalService = modalService;
        this.navigation = navigation;
        this.key = 'cancel';
        this.modes = ['edit', 'detail'];
    }
    run(data) {
        if (data.itemStore.recordStore.isDirty()) {
            this.showConfirmationModal(data);
            return;
        }
        this.cancel(data);
    }
    shouldDisplay() {
        return true;
    }
    cancel(data) {
        data.itemStore.recordStore.resetStaging();
        data.itemStore.setMode('detail');
    }
    showConfirmationModal(data) {
        const modal = this.modalService.open(MessageModalComponent);
        modal.componentInstance.textKey = 'WARN_UNSAVED_CHANGES';
        modal.componentInstance.buttons = [
            {
                labelKey: 'LBL_CANCEL',
                klass: ['btn-secondary'],
                onClick: activeModal => activeModal.dismiss()
            },
            {
                labelKey: 'LBL_PROCEED',
                klass: ['btn-main'],
                onClick: activeModal => {
                    this.cancel(data);
                    activeModal.close();
                }
            },
        ];
    }
    static { this.ɵfac = function RecordThreadItemCancelAction_Factory(t) { return new (t || RecordThreadItemCancelAction)(i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(ModuleNavigation)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemCancelAction, factory: RecordThreadItemCancelAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemCancelAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i3$1.NgbModal }, { type: ModuleNavigation }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemEditAction extends RecordThreadItemActionHandler {
    constructor() {
        super();
        this.key = 'edit';
        this.modes = ['detail'];
    }
    run(data) {
        data.itemStore.setMode('edit');
    }
    shouldDisplay(data) {
        return this.checkRecordAccess(data, ['edit']);
    }
    static { this.ɵfac = function RecordThreadItemEditAction_Factory(t) { return new (t || RecordThreadItemEditAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemEditAction, factory: RecordThreadItemEditAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemEditAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemSaveAction extends RecordThreadItemActionHandler {
    constructor(message, navigation) {
        super();
        this.message = message;
        this.navigation = navigation;
        this.key = 'save';
        this.modes = ['edit'];
    }
    run(data) {
        data.itemStore.recordStore.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                data.itemStore.save().pipe(take(1)).subscribe(record => {
                    data.itemStore.setMode('detail');
                });
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function RecordThreadItemSaveAction_Factory(t) { return new (t || RecordThreadItemSaveAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(ModuleNavigation)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemSaveAction, factory: RecordThreadItemSaveAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemSaveAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: ModuleNavigation }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemActionManager extends BaseActionManager {
    constructor(async, cancel, edit, save) {
        super();
        this.async = async;
        this.cancel = cancel;
        this.edit = edit;
        this.save = save;
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
        edit.modes.forEach(mode => this.actions[mode][edit.key] = edit);
        save.modes.forEach(mode => this.actions[mode][save.key] = save);
        cancel.modes.forEach(mode => this.actions[mode][cancel.key] = cancel);
    }
    static { this.ɵfac = function RecordThreadItemActionManager_Factory(t) { return new (t || RecordThreadItemActionManager)(i0.ɵɵinject(AsyncProcessRecordThreadItemAction), i0.ɵɵinject(RecordThreadItemCancelAction), i0.ɵɵinject(RecordThreadItemEditAction), i0.ɵɵinject(RecordThreadItemSaveAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemActionManager, factory: RecordThreadItemActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AsyncProcessRecordThreadItemAction }, { type: RecordThreadItemCancelAction }, { type: RecordThreadItemEditAction }, { type: RecordThreadItemSaveAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemActionsAdapter extends BaseRecordActionsAdapter {
    constructor(itemStore, threadStore, language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.itemStore = itemStore;
        this.threadStore = threadStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.defaultActions = {
            detail: [],
            edit: [],
            create: [],
        };
        this.collapseButtons = false;
    }
    getActions(context) {
        return this.itemStore.meta$.pipe(combineLatestWith(this.itemStore.mode$), map(([meta, mode]) => {
            if (!mode || !meta) {
                return [];
            }
            return this.parseModeActions(meta.actions, mode, this.itemStore.getViewContext());
        }));
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `record-thread-item-${action.key}`;
    }
    buildActionData(action, context) {
        return {
            itemStore: this.itemStore,
            threadStore: this.threadStore,
            action: action
        };
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const baseRecord = this.itemStore.getBaseRecord();
        this.message.removeMessages();
        return {
            action: actionName,
            module: baseRecord.module,
            id: baseRecord.id,
            params: (action && action.params) || []
        };
    }
    getMode() {
        return this.itemStore.getMode();
    }
    getModuleName(context) {
        return this.itemStore.getModuleName();
    }
    reload(action, process, context) {
        const reload = process?.data?.reload ?? false;
        const reloadThread = process?.data?.reloadThread ?? false;
        if (isTrue(reload)) {
            this.itemStore.load(false).pipe(take(1)).subscribe();
        }
        if (isTrue(reloadThread)) {
            this.threadStore.reload();
        }
    }
    /**
     * @inheritDoc
     */
    shouldReload(process) {
        const reload = process?.data?.reload ?? false;
        const reloadThread = process?.data?.reloadThread ?? false;
        return isTrue(reload) || isTrue(reloadThread);
    }
    static { this.ɵfac = function RecordThreadItemActionsAdapter_Factory(t) { return new (t || RecordThreadItemActionsAdapter)(i0.ɵɵinject(RecordThreadItemStore), i0.ɵɵinject(RecordThreadStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordThreadItemActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemActionsAdapter, factory: RecordThreadItemActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordThreadItemStore }, { type: RecordThreadStore }, { type: LanguageStore }, { type: RecordThreadItemActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemActionsAdapterFactory {
    constructor(language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(itemStore, threadStore, config = null) {
        const adapter = new RecordThreadItemActionsAdapter(itemStore, threadStore, this.language, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.selectModalService, this.metadata, this.appMetadataStore);
        const collapseButtons = config?.metadata?.collapseActions ?? null;
        if (collapseButtons !== null) {
            adapter.collapseButtons = collapseButtons;
        }
        return adapter;
    }
    static { this.ɵfac = function RecordThreadItemActionsAdapterFactory_Factory(t) { return new (t || RecordThreadItemActionsAdapterFactory)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordThreadItemActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordThreadItemActionsAdapterFactory, factory: RecordThreadItemActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LanguageStore }, { type: RecordThreadItemActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_label_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "label", 3);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const field_r11 = i0.ɵɵnextContext(3).ngIf;
    const col_r5 = i0.ɵɵnextContext(4).$implicit;
    const ctx_r15 = i0.ɵɵnextContext(4);
    i0.ɵɵproperty("ngClass", ctx_r15.getLabelClass(col_r5));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", field_r11.label, " ");
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_scrm_label_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-label", 9);
} if (rf & 2) {
    const field_r11 = i0.ɵɵnextContext(3).ngIf;
    const col_r5 = i0.ɵɵnextContext(4).$implicit;
    const ctx_r16 = i0.ɵɵnextContext(4);
    i0.ɵɵproperty("labelKey", field_r11.labelKey)("ngClass", ctx_r16.getLabelClass(col_r5));
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_scrm_dynamic_label_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-dynamic-label", 10);
} if (rf & 2) {
    const field_r11 = i0.ɵɵnextContext(3).ngIf;
    const ctx_r17 = i0.ɵɵnextContext(8);
    i0.ɵɵproperty("labelKey", field_r11.dynamicLabelKey)("fields", ctx_r17.record.fields);
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵtemplate(2, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_label_2_Template, 2, 2, "label", 6);
    i0.ɵɵtemplate(3, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_scrm_label_3_Template, 1, 2, "scrm-label", 7);
    i0.ɵɵtemplate(4, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_scrm_dynamic_label_4_Template, 1, 2, "scrm-dynamic-label", 8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const field_r11 = i0.ɵɵnextContext(2).ngIf;
    const col_r5 = i0.ɵɵnextContext(4).$implicit;
    const ctx_r13 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("pr-3", ctx_r13.getLabelDisplay(col_r5, ctx_r13.mode) === "inline" && ctx_r13.getDisplay(col_r5) !== "none");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", field_r11.label);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !field_r11.label && field_r11.labelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", field_r11.dynamicLabelKey);
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div");
    i0.ɵɵelement(2, "scrm-field", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const field_r11 = i0.ɵɵnextContext(2).ngIf;
    const col_r5 = i0.ɵɵnextContext(4).$implicit;
    const ctx_r14 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("flex-grow-1", ctx_r14.getLabelDisplay(col_r5, ctx_r14.mode) === "inline");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("field", field_r11)("klass", ctx_r14.getFieldClass(col_r5))("mode", ctx_r14.mode)("record", ctx_r14.record)("type", field_r11.type);
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_1_Template, 5, 5, "ng-container", 1);
    i0.ɵɵtemplate(2, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_ng_container_2_Template, 3, 7, "ng-container", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r5 = i0.ɵɵnextContext(5).$implicit;
    const ctx_r12 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r12.getLabelDisplay(col_r5, ctx_r12.mode) !== "none");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r12.getDisplay(col_r5) !== "none");
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_ng_container_1_Template, 3, 2, "ng-container", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const field_r11 = ctx.ngIf;
    const col_r5 = i0.ɵɵnextContext(4).$implicit;
    const ctx_r10 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.shouldDisplay(col_r5, field_r11, ctx_r10.mode));
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_ng_container_1_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r5 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r8 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.getField(ctx_r8.record, col_r5.field));
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-action-group-menu", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(7);
    let tmp_0_0;
    let tmp_1_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("buttonClass", (tmp_0_0 = ctx_r9.config.buttonClass) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "")("buttonGroupClass", (tmp_1_0 = ctx_r9.config.buttonGroupClass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "")("config", ctx_r9.config.actions);
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 5);
    i0.ɵɵtemplate(2, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_2_Template, 2, 1, "ng-container", 1);
    i0.ɵɵtemplate(3, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_ng_container_3_Template, 2, 3, "ng-container", 1);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r5 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r7 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("align-items-center", ctx_r7.getLabelDisplay(col_r5, ctx_r7.mode) === "inline")("flex-column", ctx_r7.getLabelDisplay(col_r5, ctx_r7.mode) === "top")("flex-row", ctx_r7.getLabelDisplay(col_r5, ctx_r7.mode) === "inline")("justify-content-end", !col_r5.field);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.record);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r5.actionSlot && ctx_r7.config.actions);
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_ng_container_1_Template, 4, 10, "ng-container", 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const col_r5 = i0.ɵɵnextContext().$implicit;
    const ctx_r6 = i0.ɵɵnextContext(4);
    let tmp_1_0;
    i0.ɵɵclassMapInterpolate1("record-flexbox-col ", ctx_r6.getClass(col_r5), "");
    i0.ɵɵproperty("ngClass", (tmp_1_0 = ctx_r6.config.colClass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : null);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r5.display !== "hidden" && ctx_r6.shouldColDisplayInMode(col_r5, ctx_r6.mode));
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_div_1_Template, 2, 5, "div", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const col_r5 = ctx.$implicit;
    const ctx_r4 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", col_r5.display !== "hidden" && ctx_r4.shouldColDisplayInMode(col_r5, ctx_r4.mode));
} }
function RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵtemplate(2, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_ng_container_2_Template, 2, 1, "ng-container", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r3 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext(3);
    let tmp_1_0;
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate3("d-flex record-flexbox-row ", ctx_r2.getJustify(item_r3.justify), " ", ctx_r2.getAlign(item_r3.align), " ", ctx_r2.getLayoutRowClass(item_r3), "");
    i0.ɵɵproperty("ngClass", (tmp_1_0 = ctx_r2.config.rowClass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : null);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", item_r3.cols);
} }
function RecordFlexboxComponent_div_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_ng_container_1_Template, 3, 7, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r1.layout.rows);
} }
function RecordFlexboxComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, RecordFlexboxComponent_div_0_ng_container_1_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵclassMapInterpolate2("d-flex ", (ctx_r0.config && ctx_r0.config.flexDirection ? ctx_r0.config.flexDirection : "flex-column") || "", " ", ctx_r0.config && ctx_r0.config.klass || "", "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.layout && ctx_r0.layout.rows);
} }
class RecordFlexboxComponent {
    constructor() {
        this.mode = 'detail';
        this.maxColumns = 4;
        this.sizeMap = {
            handset: 1,
            tablet: 2,
            web: 3,
            wide: 4
        };
        this.subs = [];
    }
    ngOnInit() {
        if (!this.config) {
            return;
        }
        const config = this.config;
        if (config.record$) {
            this.subs.push(config.record$.subscribe(record => {
                this.record = record ?? null;
            }));
        }
        if (config.mode$) {
            this.subs.push(config.mode$.subscribe(mode => {
                this.mode = mode ?? 'detail';
            }));
        }
        if (config.layout$) {
            this.subs.push(config.layout$.subscribe(layout => {
                this.layout = layout ?? null;
            }));
        }
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getRowClass() {
        return this.config.rowClass;
    }
    getColClass() {
        return this.config.colClass;
    }
    getSizeClass(size) {
        const sizeMap = {
            regular: 'text-regular',
            medium: 'text-medium',
            large: 'text-large',
            'x-large': 'text-x-large',
            'xx-large': 'text-xx-large',
            huge: 'text-huge'
        };
        return sizeMap[size] || 'text-regular';
    }
    getFontWeight(bold) {
        let fontWeight = 'font-weight-normal';
        if (bold && isTrue(bold)) {
            fontWeight = 'font-weight-bolder';
        }
        return fontWeight;
    }
    getColor(color) {
        const sizeMap = {
            yellow: 'text-yellow',
            blue: 'text-blue',
            green: 'text-green',
            red: 'text-red',
            purple: 'text-purple',
            dark: 'text-dark',
            grey: 'text-grey'
        };
        return sizeMap[color] || '';
    }
    getJustify(justify) {
        const justifyMap = {
            start: 'justify-content-start',
            end: 'justify-content-end',
            center: 'justify-content-center',
            between: 'justify-content-between',
            around: 'justify-content-around'
        };
        return justifyMap[justify] || '';
    }
    getAlign(align) {
        const alignMap = {
            start: 'align-items-start',
            end: 'align-items-end',
            center: 'align-items-center',
            baseline: 'align-items-baseline',
            stretch: 'align-items-stretch'
        };
        return alignMap[align] || '';
    }
    getLayoutRowClass(row) {
        return (row && row.class) || '';
    }
    getClass(layoutCol) {
        if (!layoutCol) {
            return '';
        }
        const klasses = [];
        klasses.push(layoutCol.class || '');
        layoutCol.size && klasses.push(this.getSizeClass(layoutCol.size) || '');
        layoutCol.bold && klasses.push(this.getFontWeight(layoutCol.bold) || '');
        layoutCol.color && klasses.push(this.getColor(layoutCol.color) || '');
        return klasses.join(' ');
    }
    getLabelDisplay(col, mode) {
        const displayInMode = this.shouldLabelDisplayInMode(col, mode);
        if (!displayInMode) {
            return 'none';
        }
        return col.labelDisplay || (this.config && this.config.labelDisplay) || 'inline';
    }
    getField(record, field) {
        if (!field || !field.name || !record || !record.fields) {
            return null;
        }
        return record.fields[field.name] ?? null;
    }
    getFieldClass(col) {
        let klasses = this.config.inputClass || {};
        if (col.inputClass) {
            klasses[col.inputClass] = true;
        }
        return klasses;
    }
    getLabelClass(col) {
        let klasses = this.config.labelClass || {};
        if (col.labelClass) {
            klasses[col.labelClass] = true;
        }
        return klasses;
    }
    shouldDisplay(col, field, mode) {
        const displayInMode = this.shouldFieldDisplayInMode(col, mode);
        if (!displayInMode) {
            return false;
        }
        if (!col.hideIfEmpty) {
            return true;
        }
        let hasValue = false;
        hasValue = hasValue || !!field.value;
        hasValue = hasValue || !!(field.valueList && field.valueList.length);
        hasValue = hasValue || !!(field.valueObject && Object.keys(field.valueObject).length);
        return hasValue;
    }
    shouldColDisplayInMode(col, mode) {
        return this.shouldFieldDisplayInMode(col, mode) || this.shouldLabelDisplayInMode(col, mode);
    }
    shouldFieldDisplayInMode(col, mode) {
        const modes = col?.modes ?? null;
        return !(modes && modes.length && !modes.includes(mode));
    }
    shouldLabelDisplayInMode(col, mode) {
        const modes = col?.labelModes ?? null;
        return !(modes && modes.length && !modes.includes(mode));
    }
    getDisplay(col) {
        return col.display || '';
    }
    static { this.ɵfac = function RecordFlexboxComponent_Factory(t) { return new (t || RecordFlexboxComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordFlexboxComponent, selectors: [["scrm-record-flexbox"]], inputs: { config: "config" }, decls: 1, vars: 1, consts: [[3, "class", 4, "ngIf"], [4, "ngIf"], [4, "ngFor", "ngForOf"], [3, "ngClass"], [3, "ngClass", "class", 4, "ngIf"], [1, "d-flex"], [3, "ngClass", 4, "ngIf"], [3, "labelKey", "ngClass", 4, "ngIf"], [3, "labelKey", "fields", 4, "ngIf"], [3, "labelKey", "ngClass"], [3, "labelKey", "fields"], [3, "field", "klass", "mode", "record", "type"], [3, "buttonClass", "buttonGroupClass", "config"]], template: function RecordFlexboxComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordFlexboxComponent_div_0_Template, 2, 5, "div", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.config);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, FieldComponent, LabelComponent, ActionGroupMenuComponent, DynamicLabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordFlexboxComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-flexbox', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div *ngIf=\"config\" class=\"d-flex {{((config && config.flexDirection) ? config.flexDirection : 'flex-column' ) || ''}} {{(config && config.klass) || ''}}\"   >\n    <ng-container *ngIf=\"layout && layout.rows\">\n        <ng-container *ngFor=\"let item of layout.rows\">\n\n            <div [ngClass]=\"config.rowClass ?? null\"\n                 class=\"d-flex record-flexbox-row {{getJustify(item.justify)}} {{getAlign(item.align)}} {{getLayoutRowClass(item)}}\">\n\n                <ng-container *ngFor=\"let col of item.cols\">\n\n                <div *ngIf=\"col.display !== 'hidden' && shouldColDisplayInMode(col, mode)\"\n                     [ngClass]=\"config.colClass ?? null\"\n                     class=\"record-flexbox-col {{getClass(col)}}\">\n\n                    <ng-container *ngIf=\"col.display !== 'hidden' && shouldColDisplayInMode(col, mode)\">\n\n                        <div [class.align-items-center]=\"getLabelDisplay(col, mode) === 'inline'\"\n                             [class.flex-column]=\"getLabelDisplay(col, mode) === 'top'\"\n                             [class.flex-row]=\"getLabelDisplay(col, mode) === 'inline'\"\n                             [class.justify-content-end]=\"!col.field\"\n                             class=\"d-flex\"\n                        >\n                            <ng-container *ngIf=\"record\">\n                                <ng-container *ngIf=\"getField(record, col.field) as field\">\n\n                                    <ng-container *ngIf=\"shouldDisplay(col, field, mode)\">\n                                        <ng-container *ngIf=\"getLabelDisplay(col, mode) !== 'none'\">\n\n                                            <div\n                                                [class.pr-3]=\"getLabelDisplay(col, mode) === 'inline' && getDisplay(col) !== 'none'\">\n\n                                                <label *ngIf=\"field.label\" [ngClass]=\"getLabelClass(col)\">\n                                                    {{field.label}}\n                                                </label>\n\n                                                <scrm-label *ngIf=\"!field.label && field.labelKey\"\n                                                            [labelKey]=\"field.labelKey\"\n                                                            [ngClass]=\"getLabelClass(col)\">\n                                                </scrm-label>\n\n                                                <scrm-dynamic-label *ngIf=\"field.dynamicLabelKey\"\n                                                                    [labelKey]=\"field.dynamicLabelKey\"\n                                                                    [fields]=\"record.fields\">\n                                                </scrm-dynamic-label>\n                                            </div>\n\n                                        </ng-container>\n\n                                        <ng-container *ngIf=\"getDisplay(col) !== 'none'\">\n\n                                            <div [class.flex-grow-1]=\"getLabelDisplay(col, mode) === 'inline'\">\n                                                <scrm-field [field]=\"field\"\n                                                            [klass]=\"getFieldClass(col)\"\n                                                            [mode]=\"mode\"\n                                                            [record]=\"record\"\n                                                            [type]=\"field.type\">\n                                                </scrm-field>\n\n                                            </div>\n\n                                        </ng-container>\n\n\n                                    </ng-container>\n\n                                </ng-container>\n                            </ng-container>\n\n                            <ng-container *ngIf=\"col.actionSlot && this.config.actions\">\n                                <scrm-action-group-menu [buttonClass]=\"config.buttonClass ?? ''\"\n                                                        [buttonGroupClass]=\"config.buttonGroupClass ?? ''\"\n                                                        [config]=\"config.actions\">\n                                </scrm-action-group-menu>\n                            </ng-container>\n\n                        </div>\n                    </ng-container>\n\n                </div>\n                </ng-container>\n            </div>\n        </ng-container>\n    </ng-container>\n</div>\n" }]
    }], function () { return []; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$s = ["body"];
function RecordThreadItemComponent_div_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-flexbox", 6);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r1.buildConfig(ctx_r1.config.metadata.headerLayout));
} }
function RecordThreadItemComponent_div_0_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-flexbox", 6);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r3.buildConfig(ctx_r3.config.metadata.bodyLayout));
} }
function RecordThreadItemComponent_div_0_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 7);
} }
function RecordThreadItemComponent_div_0_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "scrm-button", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r5.getCollapseButton());
} }
function RecordThreadItemComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "div", 1);
    i0.ɵɵtemplate(2, RecordThreadItemComponent_div_0_ng_container_2_Template, 2, 1, "ng-container", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", null, 3);
    i0.ɵɵtemplate(5, RecordThreadItemComponent_div_0_ng_container_5_Template, 2, 1, "ng-container", 2);
    i0.ɵɵtemplate(6, RecordThreadItemComponent_div_0_div_6_Template, 1, 0, "div", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(7, RecordThreadItemComponent_div_0_div_7_Template, 2, 1, "div", 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵclassMapInterpolate2("d-flex flex-column record-thread-item ", ctx_r0.config && ctx_r0.config.klass || "", " ", ctx_r0.dynamicClass, "");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.config.metadata && ctx_r0.config.metadata.headerLayout);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("record-thread-item-body flex-grow-1 ", ctx_r0.getBodyClass(), "");
    i0.ɵɵclassProp("collapsed", ctx_r0.collapsible && ctx_r0.collapsed)("expanded", ctx_r0.collapsible && !ctx_r0.collapsed);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.config.metadata && ctx_r0.config.metadata.bodyLayout);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.collapsible && ctx_r0.collapsed);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.collapsible);
} }
class RecordThreadItemComponent {
    constructor(actionAdapterFactory) {
        this.actionAdapterFactory = actionAdapterFactory;
        this.collapsed = false;
        this.collapsible = false;
        this.collapseLimit = 300;
        this.dynamicClass = '';
        this.subs = [];
        this.dynamicClassesMap = {};
        this.dynamicClassFieldSubs = [];
    }
    ngOnInit() {
        this.actionAdapter = this.actionAdapterFactory.create(this.config.store, this.config.threadStore, this.config);
        this.initDynamicClass();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.dynamicClassFieldSubs.forEach(sub => sub.unsubscribe());
    }
    ngAfterViewInit() {
        if (!this.config || !this.config.collapsible) {
            return;
        }
        setTimeout(() => {
            const collapseLimit = this.config.collapseLimit || this.collapseLimit;
            let height = this.bodyEl.nativeElement.offsetHeight || this.bodyEl.nativeElement.height;
            if (height > collapseLimit) {
                this.collapsible = true;
                this.collapsed = true;
            }
        }, 2000);
    }
    /**
     *
     * Build layout data source according to received configuration
     * @param {object} layout: FieldFlexboxRow[]
     * @returns {object} RecordFlexboxConfig
     */
    buildConfig(layout) {
        return {
            record$: this.config.store.stagingRecord$,
            mode$: this.config.store.mode$,
            layout$: of(layout).pipe(shareReplay(1)),
            inputClass: {
                ...(this.config.inputClass || {}),
                'form-control form-control-sm': true
            },
            buttonClass: this?.config?.buttonClass ?? '',
            buttonGroupClass: this?.config?.buttonGroupClass ?? '',
            labelClass: this?.config?.labelClass ?? {},
            rowClass: this?.config?.rowClass ?? {},
            colClass: this?.config?.colClass ?? {},
            actions: this?.actionAdapter,
            klass: this?.config?.containerClass,
            flexDirection: this?.config?.flexDirection || ''
        };
    }
    getCollapseButton() {
        return {
            klass: 'collapse-button btn btn-link btn-sm',
            labelKey: this.collapsed ? 'LBL_SHOW_MORE' : 'LBL_SHOW_LESS',
            onClick: () => {
                this.collapsed = !this.collapsed;
                if (this.collapsed) {
                    this.config && this.config.collapsed();
                }
                else {
                    this.config && this.config.expanded();
                }
            }
        };
    }
    initDynamicClass() {
        if (!this.config || !this.config.dynamicClass || !this.config.dynamicClass.length) {
            return;
        }
        this.subs.push(this.config.store.stagingRecord$.subscribe(record => {
            const klassesMap = {};
            this.dynamicClassFieldSubs.forEach(sub => sub.unsubscribe());
            if (!record || !record.fields || !Object.keys(record.fields).length) {
                return;
            }
            this.config.dynamicClass.forEach(fieldKey => {
                if (!fieldKey) {
                    return;
                }
                if (!record.fields[fieldKey] && !record.attributes[fieldKey]) {
                    return;
                }
                if (record.fields[fieldKey]) {
                    this.dynamicClassFieldSubs.push(record.fields[fieldKey].valueChanges$.pipe(debounceTime(100)).subscribe(() => {
                        const klass = this.getDynamicClasses(fieldKey, record) ?? '';
                        if (klass !== '') {
                            this.dynamicClassesMap[fieldKey] = klass;
                            this.calculateDynamicClasses();
                        }
                    }));
                }
                const klass = this.getDynamicClasses(fieldKey, record) ?? '';
                if (klass !== '') {
                    klassesMap[fieldKey] = klass;
                }
            });
            this.dynamicClassesMap = klassesMap;
            this.calculateDynamicClasses();
        }));
    }
    /**
     * Calculate dynamic classes
     */
    calculateDynamicClasses() {
        const klasses = [];
        Object.keys(this.dynamicClassesMap ?? {}).forEach(field => {
            const klass = this.dynamicClassesMap[field] ?? '';
            if (klass === '') {
                return;
            }
            klasses.push(klass);
        });
        this.dynamicClass = klasses.join(' ');
    }
    /**
     * Get Dynamic classes for record
     * @param fieldKey
     * @param record
     * @protected
     */
    getDynamicClasses(fieldKey, record) {
        const prefix = fieldKey + '-';
        let values = [];
        if (!record.fields[fieldKey]) {
            if (Array.isArray(record.attributes[fieldKey])) {
                values = values.concat(record.attributes[fieldKey]);
            }
            else if (typeof record.attributes[fieldKey] !== 'object') {
                values.push(record.attributes[fieldKey]);
            }
        }
        else {
            if (record.fields[fieldKey].value) {
                values.push(record.fields[fieldKey].value);
            }
            if (record.fields[fieldKey].valueList && record.fields[fieldKey].valueList.length) {
                values = values.concat(record.fields[fieldKey].valueList);
            }
        }
        if (!values || !values.length) {
            return '';
        }
        return prefix + values.join(' ' + prefix);
    }
    /**
     * Get body class
     */
    getBodyClass() {
        return this.config?.metadata?.bodyLayout?.class ?? '';
    }
    static { this.ɵfac = function RecordThreadItemComponent_Factory(t) { return new (t || RecordThreadItemComponent)(i0.ɵɵdirectiveInject(RecordThreadItemActionsAdapterFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordThreadItemComponent, selectors: [["scrm-record-thread-item"]], viewQuery: function RecordThreadItemComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$s, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.bodyEl = _t.first);
        } }, inputs: { config: "config" }, decls: 1, vars: 1, consts: [[3, "class", 4, "ngIf"], [1, "record-thread-item-header", "flex-grow-1"], [4, "ngIf"], ["body", ""], ["class", "fadeout", 4, "ngIf"], ["class", "record-thread-item-collapse d-flex justify-content-center flex-grow-1", 4, "ngIf"], [3, "config"], [1, "fadeout"], [1, "record-thread-item-collapse", "d-flex", "justify-content-center", "flex-grow-1"]], template: function RecordThreadItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordThreadItemComponent_div_0_Template, 8, 15, "div", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.config);
        } }, dependencies: [i2.NgIf, ButtonComponent, RecordFlexboxComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-thread-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div *ngIf=\"config\"\n     class=\"d-flex flex-column record-thread-item {{(config && config.klass) || ''}} {{dynamicClass}}\">\n    <div class=\"record-thread-item-header flex-grow-1\">\n\n        <ng-container *ngIf=\"config.metadata && config.metadata.headerLayout\">\n\n            <scrm-record-flexbox [config]=\"buildConfig(config.metadata.headerLayout)\"></scrm-record-flexbox>\n        </ng-container>\n\n    </div>\n    <div #body\n         [class.collapsed]=\"collapsible && collapsed\"\n         [class.expanded]=\"collapsible && !collapsed\"\n         class=\"record-thread-item-body flex-grow-1 {{getBodyClass()}}\">\n\n        <ng-container *ngIf=\"config.metadata && config.metadata.bodyLayout\">\n            <scrm-record-flexbox [config]=\"buildConfig(config.metadata.bodyLayout)\"></scrm-record-flexbox>\n        </ng-container>\n\n        <div *ngIf=\"collapsible && collapsed\" class=\"fadeout\"></div>\n\n    </div>\n\n    <div *ngIf=\"collapsible\" class=\"record-thread-item-collapse d-flex justify-content-center flex-grow-1\">\n        <scrm-button [config]=\"getCollapseButton()\"></scrm-button>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: RecordThreadItemActionsAdapterFactory }]; }, { config: [{
            type: Input
        }], bodyEl: [{
            type: ViewChild,
            args: ['body']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$r = ["list"];
function RecordThreadComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵelement(1, "scrm-label", 5);
    i0.ɵɵelementEnd();
} }
function RecordThreadComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-loading-spinner", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("overlay", true);
} }
function RecordThreadComponent_div_3_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵelement(1, "scrm-button", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r6.getLoadMoreButton());
} }
function RecordThreadComponent_div_3_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", null, 15);
    i0.ɵɵelement(2, "scrm-record-thread-item", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r10 = ctx.$implicit;
    const _r11 = i0.ɵɵreference(1);
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", ctx_r7.buildItem(record_r10, _r11));
} }
function RecordThreadComponent_div_3_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵelement(1, "scrm-button", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r8.getLoadMoreButton());
} }
function RecordThreadComponent_div_3_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-action-group-menu", 17);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(2);
    let tmp_0_0;
    let tmp_1_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("buttonClass", (tmp_0_0 = ctx_r9.config.listActionsButtonClass) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "")("buttonGroupClass", (tmp_1_0 = ctx_r9.config.listActionsButtonGroupClass) !== null && tmp_1_0 !== undefined ? tmp_1_0 : "")("config", ctx_r9.listActionAdapter);
} }
function RecordThreadComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8, 9);
    i0.ɵɵtemplate(2, RecordThreadComponent_div_3_div_2_Template, 2, 1, "div", 10);
    i0.ɵɵtemplate(3, RecordThreadComponent_div_3_div_3_Template, 3, 1, "div", 11);
    i0.ɵɵelementStart(4, "div");
    i0.ɵɵtemplate(5, RecordThreadComponent_div_3_div_5_Template, 2, 1, "div", 12);
    i0.ɵɵtemplate(6, RecordThreadComponent_div_3_ng_container_6_Template, 2, 3, "ng-container", 3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    let tmp_3_0;
    i0.ɵɵproperty("ngStyle", ctx_r2.getMaxHeight());
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2.loadMorePosition === "top" && !ctx_r2.allLoaded());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2.records);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap((tmp_3_0 = ctx_r2.config.listActionsClass) !== null && tmp_3_0 !== undefined ? tmp_3_0 : "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.loadMorePosition === "bottom" && !ctx_r2.allLoaded());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.config.listActions);
} }
function RecordThreadComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "h6", 18);
    i0.ɵɵelement(2, "scrm-label", 19);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", ctx_r3.config.noDataLabel || "LBL_NO_DATA");
} }
function RecordThreadComponent_ng_container_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21)(1, "div", 22);
    i0.ɵɵelement(2, "scrm-record-thread-item", 14);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 23);
    i0.ɵɵelement(4, "scrm-button", 14);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r12 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", ctx_r12.buildCreateItem());
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", ctx_r12.getCreateButton());
} }
function RecordThreadComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordThreadComponent_ng_container_5_div_1_Template, 5, 2, "div", 20);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r4.loading);
} }
class RecordThreadComponent {
    constructor(storeFactory, itemFactory, recordManager, message, actionAdapterFactory) {
        this.storeFactory = storeFactory;
        this.itemFactory = itemFactory;
        this.recordManager = recordManager;
        this.message = message;
        this.actionAdapterFactory = actionAdapterFactory;
        this.loading = false;
        this.maxHeight = 400;
        this.direction = 'asc';
        this.loadMorePosition = 'top';
        this.shouldResetScroll = false;
        this.subs = [];
    }
    ngOnInit() {
        if (!isVoid(this.config.maxListHeight)) {
            this.maxHeight = this.config.maxListHeight;
        }
        if (!this.config.module) {
            return;
        }
        if (!this.config.store) {
            this.store = this.storeFactory.create();
            this.store.setItemMetadata(this.config.itemConfig.metadata);
            this.store.setListMetadata({ actions: this.config.listActions });
            this.store.init(this.config.module, false, this?.config?.pageSize ?? null);
        }
        else {
            this.store = this.config.store;
        }
        this.direction = this.config.direction || this.direction;
        this.setLoadMorePosition();
        this.initCreate();
        this.initDataSubscription();
        if (this.config.filters$) {
            this.subs.push(this.config.filters$.subscribe(filters => {
                this.store.setFilters(filters).pipe(take(1)).subscribe(() => {
                    if (this.config.onRefresh) {
                        this.config.onRefresh();
                    }
                });
            }));
        }
        else {
            this.store.load(false).subscribe(() => {
                if (this.config.onRefresh) {
                    this.config.onRefresh();
                }
            });
        }
        const autoRefreshFrequency = this?.config?.autoRefreshFrequency ?? 0;
        if (autoRefreshFrequency && this.store) {
            const min = this.config.autoRefreshDeviationMin ?? -15;
            const max = this.config.autoRefreshDeviationMax ?? 15;
            this.subs.push(this.store.initAutoRefresh(autoRefreshFrequency, min, max, this.config.onRefresh).subscribe());
        }
        this.initLoading();
        this.listActionAdapter = this.actionAdapterFactory.create(this.store, this.config);
    }
    setLoadMorePosition() {
        this.loadMorePosition = this.direction === 'asc' ? 'top' : 'bottom';
        if (this.config.loadMorePosition) {
            this.loadMorePosition = this.config.loadMorePosition;
        }
    }
    ngAfterViewInit() {
        this.shouldResetScroll = true;
        this.resetScroll();
    }
    ngOnDestroy() {
        if (!(this?.config?.store ?? null)) {
            this.store.clear();
        }
        this.store = null;
        this.subs.forEach(sub => sub.unsubscribe());
    }
    buildItem(item, itemRef) {
        let klass = 'record-thread-list-item';
        if (this.config.itemConfig.klass) {
            klass += ' ' + this.config.itemConfig.klass;
        }
        return {
            ...this.config.itemConfig,
            store: item,
            threadStore: this.store,
            klass: klass,
            containerClass: this.config.itemConfig.containerClass,
            flexDirection: this.config?.itemConfig?.flexDirection ?? '',
            expanded: () => {
                this.scrollToItem(itemRef);
            },
            collapsed: () => {
                this.scrollToItem(itemRef);
            }
        };
    }
    getLoadMoreButton() {
        return {
            klass: 'load-more-button btn btn-link btn-sm',
            labelKey: 'LBL_LOAD_MORE',
            onClick: () => {
                if (this?.config?.onLoadMore) {
                    this.store.getRecordList().records$.pipe(take(1), tap(() => this.config.onLoadMore())).subscribe();
                }
                this.store.loadMore();
            }
        };
    }
    buildCreateItem() {
        return {
            ...this?.config?.createConfig ?? {},
            store: this.createStore,
            rowClass: { 'pt-1': true },
            klass: 'record-thread-create-item',
        };
    }
    getCreateButton() {
        return {
            klass: 'create-thread-item-button btn btn-main btn-sm',
            labelKey: 'LBL_SUBMIT_BUTTON_LABEL',
            onClick: () => {
                this.createStore.validate().pipe(take(1)).subscribe(valid => {
                    if (valid) {
                        this.createStore.save().pipe(take(1)).subscribe(() => {
                            this.store.reload();
                            this.initRecord();
                            this.shouldResetScroll = true;
                            this.message.addSuccessMessageByKey('LBL_ACTION_SUCCESS');
                        });
                        return;
                    }
                    this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
                });
            }
        };
    }
    allLoaded() {
        return !!(this.store && this.store.allLoaded());
    }
    getMaxHeight() {
        if (this.maxHeight == 0) {
            return null;
        }
        return { 'max-height.px': this.maxHeight, 'overflow-y': 'auto' };
    }
    initRecord() {
        const emptyRecord = this.recordManager.buildEmptyRecord(this.config.module);
        this.addPresetFields(emptyRecord);
        let mode = 'edit';
        if (this?.config?.createConfig && this?.config?.createConfig?.initialMode) {
            mode = this.config.createConfig.initialMode;
        }
        this.createStore.initRecord(emptyRecord, mode, false, true);
    }
    scrollToEnd() {
        if (!this.listContainer || !this.listContainer.nativeElement) {
            return;
        }
        this.scrollTo(this.listContainer.nativeElement.scrollHeight);
    }
    scrollToTop() {
        this.scrollTo(0);
    }
    scrollTo(position) {
        try {
            this.listContainer.nativeElement.scrollTop = position;
        }
        catch (err) {
        }
    }
    scrollToItem(item) {
        if (!item || !this.listContainer || !this.listContainer.nativeElement) {
            return;
        }
        const elementTop = item.offsetTop;
        const parentTop = this.listContainer.nativeElement.offsetTop;
        const relativeTop = elementTop - parentTop;
        this.scrollTo(relativeTop);
    }
    resetScroll() {
        if (this.shouldResetScroll === false) {
            return;
        }
        if (this.direction === 'asc') {
            this.scrollToEnd();
        }
        else {
            this.scrollToTop();
        }
        this.shouldResetScroll = false;
    }
    scheduleScrollReset() {
        setTimeout(() => {
            this.resetScroll();
        }, 500);
    }
    initCreate() {
        if (!this.config.create) {
            return;
        }
        this.createStore = this.itemFactory.create();
        this.createStore.setMetadata(this.config.createConfig.metadata);
        this.initRecord();
        this.initPresetFieldsMapping();
    }
    initPresetFieldsMapping() {
        if (!this.config.presetFields$) {
            return;
        }
        this.subs.push(this.config.presetFields$.subscribe(presetFieldValues => {
            if (!presetFieldValues || !Object.keys(presetFieldValues).length) {
                return;
            }
            this.presetFieldValues = presetFieldValues;
            const record = this.createStore.recordStore.getBaseRecord();
            this.addPresetFields(record);
            this.createStore.recordStore.setRecord(record);
        }));
    }
    addPresetFields(record) {
        if (!this.presetFieldValues) {
            return;
        }
        record.attributes = {
            ...this.presetFieldValues,
            ...(record.attributes || {})
        };
    }
    initDataSubscription() {
        this.subs.push(this.store.stores$.subscribe(records => {
            if (!this.records || !this.records.length) {
                this.shouldResetScroll = true;
            }
            if (this.direction === 'asc') {
                this.records = records.reverse();
                this.scheduleScrollReset();
                return;
            }
            this.records = records;
            this.scheduleScrollReset();
        }));
    }
    initLoading() {
        let loading$;
        if (this.createStore && this.createStore.loading$) {
            loading$ = this.store.$loading.pipe(combineLatestWith(this.createStore.loading$));
        }
        else {
            loading$ = this.store.$loading.pipe(map(value => [value]));
        }
        this.subs.push(loading$.subscribe((loadings) => {
            if (!loadings || !loadings.length) {
                this.loading = false;
                return;
            }
            let loading = false;
            loadings.forEach(value => {
                loading = loading || value;
            });
            this.loading = loading;
        }));
    }
    static { this.ɵfac = function RecordThreadComponent_Factory(t) { return new (t || RecordThreadComponent)(i0.ɵɵdirectiveInject(RecordThreadStoreFactory), i0.ɵɵdirectiveInject(RecordThreadItemStoreFactory), i0.ɵɵdirectiveInject(RecordManager), i0.ɵɵdirectiveInject(MessageService), i0.ɵɵdirectiveInject(RecordThreadListActionsAdapterFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordThreadComponent, selectors: [["scrm-record-thread"]], viewQuery: function RecordThreadComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$r, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.listContainer = _t.first);
        } }, inputs: { config: "config" }, decls: 6, vars: 8, consts: [["class", "d-flex record-thread-no-data justify-content-center h3", 4, "ngIf"], ["class", "d-flex record-thread-loading justify-content-center", 4, "ngIf"], ["class", "record-thread-list scrollbar-thick", 3, "ngStyle", 4, "ngIf"], [4, "ngIf"], [1, "d-flex", "record-thread-no-data", "justify-content-center", "h3"], ["labelKey", "LBL_NO_DATA"], [1, "d-flex", "record-thread-loading", "justify-content-center"], [3, "overlay"], [1, "record-thread-list", "scrollbar-thick", 3, "ngStyle"], ["list", ""], ["class", "record-thread-load-more d-flex justify-content-center flex-grow-1", 4, "ngIf"], [4, "ngFor", "ngForOf"], ["class", "record-thread-load-more d-flex justify-content-center", 4, "ngIf"], [1, "record-thread-load-more", "d-flex", "justify-content-center", "flex-grow-1"], [3, "config"], ["item", ""], [1, "record-thread-load-more", "d-flex", "justify-content-center"], [3, "buttonClass", "buttonGroupClass", "config"], [1, "pt-3", "pl-3", "pr-3", "pb-2"], [3, "labelKey"], ["class", "d-flex flex-column record-thread-create-container", 4, "ngIf"], [1, "d-flex", "flex-column", "record-thread-create-container"], [1, "flex-grow-1"], [1, "flex-grow-1", "d-flex", "justify-content-start", "pt-1", "record-thread-create-buttons"]], template: function RecordThreadComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div");
            i0.ɵɵtemplate(1, RecordThreadComponent_div_1_Template, 2, 0, "div", 0);
            i0.ɵɵtemplate(2, RecordThreadComponent_div_2_Template, 2, 1, "div", 1);
            i0.ɵɵtemplate(3, RecordThreadComponent_div_3_Template, 7, 7, "div", 2);
            i0.ɵɵtemplate(4, RecordThreadComponent_div_4_Template, 3, 1, "div", 3);
            i0.ɵɵtemplate(5, RecordThreadComponent_ng_container_5_Template, 2, 1, "ng-container", 3);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMapInterpolate1("record-thread ", ctx.config && ctx.config.klass || "", "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.loading && !ctx.records && !ctx.records.length);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.loading);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.records && ctx.records.length);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", (!ctx.records || !ctx.records.length) && !ctx.loading && ctx.config.showNoDataMessage);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.config.create && ctx.createStore);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i2.NgStyle, ButtonComponent, LabelComponent, RecordThreadItemComponent, LoadingSpinnerComponent, ActionGroupMenuComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-thread', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"record-thread {{(config && config.klass) || ''}}\">\n    <div *ngIf=\"!loading && !records && !records.length\"\n         class=\"d-flex record-thread-no-data justify-content-center h3\">\n        <scrm-label labelKey=\"LBL_NO_DATA\"></scrm-label>\n    </div>\n\n    <div *ngIf=\"loading\" class=\"d-flex record-thread-loading justify-content-center\">\n        <scrm-loading-spinner [overlay]=\"true\"></scrm-loading-spinner>\n    </div>\n\n    <div #list\n         *ngIf=\"records && records.length\"\n         [ngStyle]=\"getMaxHeight()\"\n         class=\"record-thread-list scrollbar-thick\">\n\n        <div *ngIf=\"loadMorePosition === 'top' && !allLoaded()\"\n             class=\"record-thread-load-more d-flex justify-content-center flex-grow-1\">\n            <scrm-button [config]=\"getLoadMoreButton()\"></scrm-button>\n        </div>\n\n        <div #item *ngFor=\"let record of records\">\n            <scrm-record-thread-item [config]=\"buildItem(record, item)\"></scrm-record-thread-item>\n        </div>\n\n        <div [class]=\"config.listActionsClass ?? ''\">\n\n            <div *ngIf=\"loadMorePosition === 'bottom' && !allLoaded()\"\n                 class=\"record-thread-load-more d-flex justify-content-center\">\n                <scrm-button [config]=\"getLoadMoreButton()\"></scrm-button>\n            </div>\n\n            <ng-container *ngIf=\"config.listActions\">\n                <scrm-action-group-menu [buttonClass]=\"config.listActionsButtonClass ?? ''\"\n                                        [buttonGroupClass]=\"config.listActionsButtonGroupClass ?? ''\"\n                                        [config]=\"listActionAdapter\">\n                </scrm-action-group-menu>\n            </ng-container>\n\n        </div>\n\n    </div>\n\n    <div *ngIf=\"(!records || !records.length) && !loading && config.showNoDataMessage\">\n        <h6 class=\"pt-3 pl-3 pr-3 pb-2\">\n            <scrm-label [labelKey]=\"config.noDataLabel || 'LBL_NO_DATA'\"></scrm-label>\n        </h6>\n\n    </div>\n\n    <ng-container *ngIf=\"config.create && createStore\">\n\n        <div *ngIf=\"!loading\"\n             class=\"d-flex flex-column record-thread-create-container\">\n\n            <div class=\"flex-grow-1\">\n                <scrm-record-thread-item [config]=\"buildCreateItem()\"></scrm-record-thread-item>\n            </div>\n\n            <div class=\"flex-grow-1 d-flex justify-content-start pt-1 record-thread-create-buttons\">\n                <scrm-button [config]=\"getCreateButton()\"></scrm-button>\n            </div>\n\n        </div>\n\n    </ng-container>\n\n</div>\n" }]
    }], function () { return [{ type: RecordThreadStoreFactory }, { type: RecordThreadItemStoreFactory }, { type: RecordManager }, { type: MessageService }, { type: RecordThreadListActionsAdapterFactory }]; }, { config: [{
            type: Input
        }], listContainer: [{
            type: ViewChild,
            args: ['list']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function NotificationsComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 2);
    i0.ɵɵelement(2, "scrm-label", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function NotificationsComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-thread", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r1.recordThreadConfig);
} }
class NotificationsComponent {
    constructor(language, systemConfig, message, notificationService, notificationStore) {
        this.language = language;
        this.systemConfig = systemConfig;
        this.message = message;
        this.notificationService = notificationService;
        this.notificationStore = notificationStore;
    }
    ngOnInit() {
        this.options = this.notificationService.getOptions();
        this.recordThreadConfig = this.getConfig();
    }
    getConfig() {
        const config = {
            filters$: of({
                orderBy: this?.options?.filters?.orderBy ?? 'date_entered',
                sortOrder: this?.options?.filters?.sortOrder ?? 'asc',
                preset: { type: 'alerts' }
            }),
            module: this.options.module,
            klass: this.options.class ?? '',
            maxListHeight: this.options.maxListHeight ?? 350,
            direction: this.options.direction || 'asc',
            autoRefreshFrequency: this.options.autoRefreshFrequency || 0,
            autoRefreshDeviationMin: this.options.autoRefreshDeviationMin ?? 0,
            autoRefreshDeviationMax: this.options.autoRefreshDeviationMax ?? 0,
            onRefresh: () => {
                this.notificationService.onRefresh(this.store, this.notificationStore);
            },
            onLoadMore: () => {
                this.notificationService.onLoadMore(this.notificationStore);
            },
            loadMorePosition: this.options?.loadMorePosition ?? '',
            create: false,
            listActionsClass: this.options?.listActionsClass ?? '',
            listActionsButtonClass: this.options?.listActionsButtonClass ?? '',
            listActionsButtonGroupClass: this.options?.listActionsButtonGroupClass ?? '',
            pageSize: this.options?.pageSize ?? '',
            showNoDataMessage: this.options?.showNoDataMessage,
            noDataLabel: this.options?.noDataLabel,
        };
        this.notificationService.setupListActions(config, this.options);
        this.notificationService.setupItemConfig(config, this.options);
        config.store = this.notificationStore.getNotificationStore();
        this.store = this.notificationStore.getNotificationStore();
        return config;
    }
    static { this.ɵfac = function NotificationsComponent_Factory(t) { return new (t || NotificationsComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MessageService), i0.ɵɵdirectiveInject(NotificationsService), i0.ɵɵdirectiveInject(NotificationStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NotificationsComponent, selectors: [["scrm-notifications"]], decls: 3, vars: 2, consts: [["widget-body", "", 1, "notifications"], [4, "ngIf"], [1, "p-3", "widget-message"], ["labelKey", "LBL_BAD_CONFIG"], [3, "config"]], template: function NotificationsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, NotificationsComponent_ng_container_1_Template, 3, 0, "ng-container", 1);
            i0.ɵɵtemplate(2, NotificationsComponent_ng_container_2_Template, 2, 1, "ng-container", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.options);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.options);
        } }, dependencies: [i2.NgIf, LabelComponent, RecordThreadComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationsComponent, [{
        type: Component,
        args: [{ selector: 'scrm-notifications', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"notifications\" widget-body>\n\n    <ng-container *ngIf=\"!options\">\n        <div class=\"p-3 widget-message\">\n            <scrm-label labelKey=\"LBL_BAD_CONFIG\"></scrm-label>\n        </div>\n    </ng-container>\n\n    <ng-container *ngIf=\"options\">\n        <scrm-record-thread [config]=\"recordThreadConfig\"></scrm-record-thread>\n    </ng-container>\n\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: SystemConfigStore }, { type: MessageService }, { type: NotificationsService }, { type: NotificationStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecentlyViewedComponent_ng_container_0_li_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 4)(1, "a", 5);
    i0.ɵɵelement(2, "scrm-image", 6);
    i0.ɵɵelementStart(3, "div", 7)(4, "span", 8);
    i0.ɵɵelement(5, "scrm-label", 9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "span", 10);
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const item_r4 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", item_r4.attributes == null ? null : item_r4.attributes.route);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("image", item_r4 == null ? null : item_r4.attributes == null ? null : item_r4.attributes.module_name);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("labelKey", item_r4 == null ? null : item_r4.attributes == null ? null : item_r4.attributes.module_name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(item_r4 == null ? null : item_r4.attributes == null ? null : item_r4.attributes.item_summary);
} }
function RecentlyViewedComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "ul", 2);
    i0.ɵɵtemplate(2, RecentlyViewedComponent_ng_container_0_li_2_Template, 8, 4, "li", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r0.itemWithRoutes());
} }
function RecentlyViewedComponent_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "h6", 11);
    i0.ɵɵelement(1, "scrm-label", 12);
    i0.ɵɵelementEnd();
} }
class RecentlyViewedComponent {
    set menuItems(value) {
        this._menuItems.set(value);
    }
    constructor(nameMapper, navigation) {
        this.nameMapper = nameMapper;
        this.navigation = navigation;
        this._menuItems = signal([]);
        this.itemWithRoutes = computed(() => this._menuItems().map(item => {
            if (item.attributes?.route) {
                return item;
            }
            return {
                ...item,
                attributes: {
                    ...item.attributes,
                    route: this.buildRoute(item)
                }
            };
        }));
    }
    /**
     * Build route from recently viewed item
     * @param item
     */
    buildRoute(item) {
        const legacyName = item.attributes.module_name ?? '';
        const module = this.nameMapper.toFrontend(legacyName) ?? '';
        const id = item.attributes.item_id ?? '';
        return this.navigation.getRecordRouterLink(module, id);
    }
    static { this.ɵfac = function RecentlyViewedComponent_Factory(t) { return new (t || RecentlyViewedComponent)(i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(ModuleNavigation)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecentlyViewedComponent, selectors: [["scrm-recently-viewed"]], inputs: { menuItems: "menuItems" }, standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 2, consts: [[4, "ngIf", "ngIfElse"], ["noItems", ""], [1, "p-0", "mb-0"], ["class", "recently-viewed-header d-flex", 4, "ngFor", "ngForOf"], [1, "recently-viewed-header", "d-flex"], [1, "new-list-item", "d-flex", 3, "routerLink"], [1, "action-btn-icon", "mr-3", 3, "image"], [1, "d-flex", "flex-column"], [1, "text-title", "text-uppercase"], ["listKey", "moduleList", 3, "labelKey"], [1, "text-subtitle"], [1, "d-flex", "justify-content-center", "pt-3", "pb-2"], ["labelKey", "LBL_LAST_VIEWED_NO_RESULT"]], template: function RecentlyViewedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecentlyViewedComponent_ng_container_0_Template, 3, 1, "ng-container", 0);
            i0.ɵɵtemplate(1, RecentlyViewedComponent_ng_template_1_Template, 2, 0, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            const _r1 = i0.ɵɵreference(2);
            i0.ɵɵproperty("ngIf", ctx.itemWithRoutes() && ctx.itemWithRoutes().length)("ngIfElse", _r1);
        } }, dependencies: [CommonModule, i2.NgForOf, i2.NgIf, ImageModule, ImageComponent, RouterLink, LabelModule, LabelComponent], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecentlyViewedComponent, [{
        type: Component,
        args: [{ selector: 'scrm-recently-viewed', standalone: true, imports: [CommonModule, ImageModule, RouterLink, LabelModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"itemWithRoutes() && itemWithRoutes().length; else noItems\">\n    <ul class=\"p-0 mb-0\">\n        <li *ngFor=\"let item of itemWithRoutes();\" class=\"recently-viewed-header d-flex\">\n            <a class=\"new-list-item d-flex\" [routerLink]=\"item.attributes?.route\">\n                <scrm-image class=\"action-btn-icon mr-3\" [image]=\"item?.attributes?.module_name\"></scrm-image>\n                <div class=\"d-flex flex-column\">\n                <span class=\"text-title text-uppercase\">\n                    <scrm-label listKey=\"moduleList\" [labelKey]=\"item?.attributes?.module_name\"></scrm-label>\n                </span>\n                    <span class=\"text-subtitle\">{{ item?.attributes?.item_summary }}</span>\n                </div>\n            </a>\n        </li>\n    </ul>\n</ng-container>\n<ng-template #noItems>\n    <h6 class=\"d-flex justify-content-center pt-3 pb-2\">\n        <scrm-label labelKey=\"LBL_LAST_VIEWED_NO_RESULT\"></scrm-label>\n    </h6>\n</ng-template>\n\n\n\n" }]
    }], function () { return [{ type: ModuleNameMapper }, { type: ModuleNavigation }]; }, { menuItems: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function BaseMenuItemLinkComponent_ng_container_0_scrm_image_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 3);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("image", ctx_r3.icon);
} }
function BaseMenuItemLinkComponent_ng_container_0_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "truncate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, ctx_r4.link.label, ctx_r4.charSize.mediumLength));
} }
function BaseMenuItemLinkComponent_ng_container_0_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "truncate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, ctx_r5.link.label, ctx_r5.charSize.maxLength));
} }
function BaseMenuItemLinkComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 1);
    i0.ɵɵlistener("click", function BaseMenuItemLinkComponent_ng_container_0_Template_a_click_1_listener($event) { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.config.onClick($event)); })("touchstart", function BaseMenuItemLinkComponent_ng_container_0_Template_a_touchstart_1_listener($event) { i0.ɵɵrestoreView(_r7); const ctx_r8 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r8.config.onTouchStart($event)); });
    i0.ɵɵtemplate(2, BaseMenuItemLinkComponent_ng_container_0_scrm_image_2_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtemplate(3, BaseMenuItemLinkComponent_ng_container_0_span_3_Template, 3, 4, "span", 0);
    i0.ɵɵtemplate(4, BaseMenuItemLinkComponent_ng_container_0_span_4_Template, 3, 4, "span", 0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r0.class);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.link.params);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.link.params);
} }
function BaseMenuItemLinkComponent_ng_container_1_a_1_scrm_image_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 3);
} if (rf & 2) {
    const ctx_r12 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("image", ctx_r12.icon);
} }
function BaseMenuItemLinkComponent_ng_container_1_a_1_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "truncate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r13 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, ctx_r13.link.label, ctx_r13.charSize.mediumLength));
} }
function BaseMenuItemLinkComponent_ng_container_1_a_1_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "truncate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r14 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, ctx_r14.link.label, ctx_r14.charSize.maxLength));
} }
function BaseMenuItemLinkComponent_ng_container_1_a_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 7);
    i0.ɵɵtemplate(1, BaseMenuItemLinkComponent_ng_container_1_a_1_scrm_image_1_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtemplate(2, BaseMenuItemLinkComponent_ng_container_1_a_1_span_2_Template, 3, 4, "span", 0);
    i0.ɵɵtemplate(3, BaseMenuItemLinkComponent_ng_container_1_a_1_span_3_Template, 3, 4, "span", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", ctx_r9.class)("queryParams", ctx_r9.link.params)("routerLink", ctx_r9.link.route);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r9.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r9.link.params);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r9.link.params);
} }
function BaseMenuItemLinkComponent_ng_container_1_a_2_scrm_image_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 3);
} if (rf & 2) {
    const ctx_r15 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("image", ctx_r15.icon);
} }
function BaseMenuItemLinkComponent_ng_container_1_a_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 8);
    i0.ɵɵtemplate(1, BaseMenuItemLinkComponent_ng_container_1_a_2_scrm_image_1_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r10 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("href", ctx_r10.link.url, i0.ɵɵsanitizeUrl)("ngClass", ctx_r10.class);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r10.link.label, " ");
} }
function BaseMenuItemLinkComponent_ng_container_1_a_3_scrm_image_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 3);
} if (rf & 2) {
    const ctx_r16 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("image", ctx_r16.icon);
} }
function BaseMenuItemLinkComponent_ng_container_1_a_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 9);
    i0.ɵɵtemplate(1, BaseMenuItemLinkComponent_ng_container_1_a_3_scrm_image_1_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r11 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngClass", ctx_r11.class);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r11.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r11.link.label, " ");
} }
function BaseMenuItemLinkComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseMenuItemLinkComponent_ng_container_1_a_1_Template, 4, 6, "a", 4);
    i0.ɵɵtemplate(2, BaseMenuItemLinkComponent_ng_container_1_a_2_Template, 3, 4, "a", 5);
    i0.ɵɵtemplate(3, BaseMenuItemLinkComponent_ng_container_1_a_3_Template, 3, 3, "a", 6);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.link.route);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r1.link.route && ctx_r1.link.url);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r1.link.route && !ctx_r1.link.url);
} }
function BaseMenuItemLinkComponent_ng_container_2_scrm_image_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-image", 3);
} if (rf & 2) {
    const ctx_r17 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("image", ctx_r17.icon);
} }
function BaseMenuItemLinkComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r19 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 10);
    i0.ɵɵlistener("click", function BaseMenuItemLinkComponent_ng_container_2_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r18.handleProcess(ctx_r18.link.process)); });
    i0.ɵɵtemplate(2, BaseMenuItemLinkComponent_ng_container_2_scrm_image_2_Template, 1, 1, "scrm-image", 2);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r2.class);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r2.link.label, " ");
} }
class BaseMenuItemLinkComponent {
    constructor(asyncActionService, systemConfigStore, appState) {
        this.asyncActionService = asyncActionService;
        this.systemConfigStore = systemConfigStore;
        this.appState = appState;
        this.charSize = {
            minLength: 20,
            mediumLength: 20,
            maxLength: 20
        };
    }
    ngOnInit() {
        const characterSizes = this.systemConfigStore.getUi('navbar_truncate_character_sizes');
        this.charSize = { ...characterSizes };
    }
    handleProcess(process) {
        if (!process) {
            return;
        }
        const processType = process;
        const options = {
            action: processType,
            module: this.appState.getModule(),
        };
        this.asyncActionService.run(processType, options).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function BaseMenuItemLinkComponent_Factory(t) { return new (t || BaseMenuItemLinkComponent)(i0.ɵɵdirectiveInject(AsyncActionService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(AppStateStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMenuItemLinkComponent, selectors: [["scrm-base-menu-item-link"]], inputs: { link: "link", icon: "icon", class: "class", config: "config" }, decls: 3, vars: 3, consts: [[4, "ngIf"], [3, "ngClass", "click", "touchstart"], [3, "image", 4, "ngIf"], [3, "image"], [3, "ngClass", "queryParams", "routerLink", 4, "ngIf"], [3, "href", "ngClass", 4, "ngIf"], [3, "ngClass", 4, "ngIf"], [3, "ngClass", "queryParams", "routerLink"], [3, "href", "ngClass"], [3, "ngClass"], [3, "ngClass", "click"]], template: function BaseMenuItemLinkComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseMenuItemLinkComponent_ng_container_0_Template, 5, 4, "ng-container", 0);
            i0.ɵɵtemplate(1, BaseMenuItemLinkComponent_ng_container_1_Template, 4, 3, "ng-container", 0);
            i0.ɵɵtemplate(2, BaseMenuItemLinkComponent_ng_container_2_Template, 4, 3, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.link.process && (ctx.config == null ? null : ctx.config.onClick));
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.link.process && !(ctx.config == null ? null : ctx.config.onClick));
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.link.process);
        } }, dependencies: [i2.NgClass, i2.NgIf, i1$2.RouterLink, ImageComponent, TruncatePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMenuItemLinkComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-menu-item-link', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!link.process && config?.onClick\">\n    <a (click)=\"config.onClick($event)\"\n       (touchstart)=\"config.onTouchStart($event)\"\n       [ngClass]=\"class\"\n    >\n        <scrm-image *ngIf=\"icon\" image=\"{{ icon }}\"></scrm-image>\n        <span *ngIf=\"!link.params\">{{ link.label | truncate: charSize.mediumLength }}</span>\n        <span *ngIf=\"link.params\">{{ link.label | truncate: charSize.maxLength }}</span>\n    </a>\n</ng-container>\n<ng-container *ngIf=\"!link.process && !config?.onClick\">\n    <a *ngIf=\"link.route\"\n       [ngClass]=\"class\"\n       [queryParams]=\"link.params\"\n       [routerLink]=\"link.route\"\n    >\n        <scrm-image *ngIf=\"icon\" image=\"{{ icon }}\"></scrm-image>\n        <span *ngIf=\"!link.params\">{{ link.label | truncate: charSize.mediumLength  }}</span>\n        <span *ngIf=\"link.params\">{{ link.label | truncate: charSize.maxLength  }}</span>\n    </a>\n    <a *ngIf=\"!link.route && link.url\"\n       [href]=\"link.url\"\n       [ngClass]=\"class\"\n    >\n        <scrm-image *ngIf=\"icon\" image=\"{{ icon }}\"></scrm-image>\n        {{ link.label }}\n    </a>\n    <a *ngIf=\"!link.route && !link.url\"\n       [ngClass]=\"class\"\n    >\n        <scrm-image *ngIf=\"icon\" image=\"{{ icon }}\"></scrm-image>\n        {{ link.label }}\n    </a>\n</ng-container>\n<ng-container *ngIf=\"link.process\">\n    <a [ngClass]=\"class\" (click)=\"handleProcess(link.process)\">\n        <scrm-image *ngIf=\"icon\" image=\"{{ icon }}\"></scrm-image>\n        {{ link.label }}\n    </a>\n</ng-container>\n\n\n" }]
    }], function () { return [{ type: AsyncActionService }, { type: SystemConfigStore }, { type: AppStateStore }]; }, { link: [{
            type: Input
        }], icon: [{
            type: Input
        }], class: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MenuItemLinkRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseMenuItemLinkComponent);
    }
    static { this.ɵfac = function MenuItemLinkRegistry_Factory(t) { return new (t || MenuItemLinkRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MenuItemLinkRegistry, factory: MenuItemLinkRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemLinkRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$q = function (a0, a1, a2, a3) { return { "link": a0, "icon": a1, "class": a2, "config": a3 }; };
function MenuItemLinkComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction4(2, _c0$q, ctx_r0.link, ctx_r0.icon, ctx_r0.class, ctx_r0.config));
} }
class MenuItemLinkComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function MenuItemLinkComponent_Factory(t) { return new (t || MenuItemLinkComponent)(i0.ɵɵdirectiveInject(MenuItemLinkRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MenuItemLinkComponent, selectors: [["scrm-menu-item-link"]], inputs: { link: "link", icon: "icon", class: "class", config: "config" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function MenuItemLinkComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MenuItemLinkComponent_ndc_dynamic_0_Template, 1, 7, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemLinkComponent, [{
        type: Component,
        args: [{ selector: 'scrm-menu-item-link', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'link': link, 'icon': icon, 'class': class, 'config': config}\">\n</ndc-dynamic>\n\n" }]
    }], function () { return [{ type: MenuItemLinkRegistry }]; }, { link: [{
            type: Input
        }], icon: [{
            type: Input
        }], class: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$p = function (a0, a1, a2) { return { label: a0, url: a1, route: a2 }; };
function BaseSubMenuRecentlyViewedComponent_ng_container_0_li_6_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 7);
    i0.ɵɵlistener("click", function BaseSubMenuRecentlyViewedComponent_ng_container_0_li_6_Template_li_click_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r3 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r3.onItemClick($event)); })("touchstart", function BaseSubMenuRecentlyViewedComponent_ng_container_0_li_6_Template_li_touchstart_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r5 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r5.onItemTouchStart($event)); });
    i0.ɵɵelement(1, "scrm-menu-item-link", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const recentRecord_r2 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap("submenu-nav-link nav-link action-link");
    i0.ɵɵproperty("link", i0.ɵɵpureFunction3(3, _c0$p, recentRecord_r2.attributes.item_summary, ctx_r1.buildRoute(recentRecord_r2), ctx_r1.buildRoute(recentRecord_r2)));
} }
function BaseSubMenuRecentlyViewedComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 1)(2, "a", 2);
    i0.ɵɵlistener("touchstart", function BaseSubMenuRecentlyViewedComponent_ng_container_0_Template_a_touchstart_2_listener($event) { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.onTouchStart($event)); })("click", function BaseSubMenuRecentlyViewedComponent_ng_container_0_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r7); const ctx_r8 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r8.toggleDropdown()); });
    i0.ɵɵelement(3, "scrm-image", 3)(4, "scrm-label", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "ul", 5);
    i0.ɵɵtemplate(6, BaseSubMenuRecentlyViewedComponent_ng_container_0_li_6_Template, 2, 7, "li", 6);
    i0.ɵɵpipe(7, "slice");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵclassProp("active", ctx_r0.showDropdown());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind3(7, 3, ctx_r0.records, 0, ctx_r0.maxDisplayed));
} }
class BaseSubMenuRecentlyViewedComponent {
    constructor(navigation, nameMapper, configs, metadata) {
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.configs = configs;
        this.metadata = metadata;
        this.maxDisplayed = 5;
        this.subs = [];
        this.showDropdown = signal(false);
        this.clickType = 'click';
    }
    ngOnInit() {
        const ui = this.configs.getConfigValue('ui') ?? {};
        this.maxDisplayed = parseInt(ui.navigation_max_module_recently_viewed) ?? 5;
        this.initMetadata$();
    }
    ngOnDestroy() {
        this.clear();
    }
    ngOnChanges(changes) {
        const moduleChanges = changes?.module ?? null;
        if (moduleChanges === null) {
            return;
        }
        const previousModule = changes?.module?.previousValue ?? '';
        const currentModule = changes?.module?.currentValue ?? '';
        if (previousModule !== currentModule) {
            this.clear();
            this.initMetadata$();
        }
    }
    /**
     * Build route from recently viewed item
     * @param item
     */
    buildRoute(item) {
        const legacyName = item.attributes.module_name ?? '';
        const module = this.nameMapper.toFrontend(legacyName) ?? '';
        const id = item.attributes.item_id ?? '';
        return this.navigation.getRecordRouterLink(module, id);
    }
    /**
     * Init metadata subscription
     * @protected
     */
    initMetadata$() {
        const moduleMeta$ = this.metadata.allModuleMetadata$.pipe(map(value => value[this.module] ?? null));
        this.subs.push(moduleMeta$.subscribe(meta => {
            this.records = meta?.recentlyViewed ?? null;
        }));
        if (this?.config?.showDropdown$) {
            this.subs.push(this.config.showDropdown$.subscribe(showDropdown => {
                this.showDropdown.set(showDropdown);
            }));
        }
    }
    /**
     * Clear subscription and data
     * @protected
     */
    clear() {
        this.records = null;
        this.subs.forEach(sub => sub.unsubscribe());
    }
    toggleDropdown() {
        if (this.clickType === 'touch') {
            this.showDropdown.set(!this.showDropdown());
            this.clickType = 'click';
            this?.config?.onToggleDropdown(this.showDropdown());
            return;
        }
    }
    onTouchStart(event) {
        this.clickType = 'touch';
    }
    onItemClick($event) {
        this.toggleDropdown();
        this?.config?.onItemClick($event);
    }
    onItemTouchStart($event) {
        this.onTouchStart($event);
        this?.config?.onItemTouchStart($event);
    }
    static { this.ɵfac = function BaseSubMenuRecentlyViewedComponent_Factory(t) { return new (t || BaseSubMenuRecentlyViewedComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseSubMenuRecentlyViewedComponent, selectors: [["scrm-base-sub-menu-recently-viewed"]], inputs: { module: "module", config: "config" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "nav-item", "dropdown-submenu", "submenu", "submenu-extra"], [1, "sub-nav-link", "nav-link", "action-link", "dropdown-item", "dropdown-toggle", "pr-4", 3, "touchstart", "click"], ["image", "clock"], ["labelKey", "LBL_LAST_VIEWED"], [1, "dropdown-menu", "submenu"], ["class", "nav-item", 3, "click", "touchstart", 4, "ngFor", "ngForOf"], [1, "nav-item", 3, "click", "touchstart"], [3, "link"]], template: function BaseSubMenuRecentlyViewedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseSubMenuRecentlyViewedComponent_ng_container_0_Template, 8, 7, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.records && ctx.records.length);
        } }, dependencies: [i2.NgForOf, i2.NgIf, ImageComponent, LabelComponent, MenuItemLinkComponent, i2.SlicePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseSubMenuRecentlyViewedComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-sub-menu-recently-viewed', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"records && records.length\">\n    <li class=\"nav-item dropdown-submenu submenu submenu-extra\">\n\n        <a class=\"sub-nav-link nav-link action-link dropdown-item dropdown-toggle pr-4\"\n           (touchstart)=\"onTouchStart($event)\"\n           (click)=\"toggleDropdown()\">\n            <scrm-image image=\"clock\"></scrm-image>\n            <scrm-label labelKey=\"LBL_LAST_VIEWED\"></scrm-label>\n        </a>\n\n        <ul class=\"dropdown-menu submenu\"\n            [class.active]=\"showDropdown()\"\n        >\n            <li *ngFor=\"let recentRecord of records | slice:0:maxDisplayed\"\n                class=\"nav-item\"\n                (click)=\"onItemClick($event)\"\n                (touchstart)=\"onItemTouchStart($event)\"\n            >\n                <scrm-menu-item-link [class]=\"'submenu-nav-link nav-link action-link'\"\n                                     [link]=\"{\n                                                label: recentRecord.attributes.item_summary,\n                                                url: buildRoute(recentRecord),\n                                                route: buildRoute(recentRecord)\n                                             }\">\n                </scrm-menu-item-link>\n            </li>\n        </ul>\n    </li>\n</ng-container>\n\n\n\n" }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: SystemConfigStore }, { type: MetadataStore }]; }, { module: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubMenuRecentlyViewedRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseSubMenuRecentlyViewedComponent);
    }
    static { this.ɵfac = function SubMenuRecentlyViewedRegistry_Factory(t) { return new (t || SubMenuRecentlyViewedRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubMenuRecentlyViewedRegistry, factory: SubMenuRecentlyViewedRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubMenuRecentlyViewedRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$o = function (a0, a1) { return { "module": a0, "config": a1 }; };
function SubMenuRecentlyViewedComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction2(2, _c0$o, ctx_r0.module, ctx_r0.config));
} }
class SubMenuRecentlyViewedComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function SubMenuRecentlyViewedComponent_Factory(t) { return new (t || SubMenuRecentlyViewedComponent)(i0.ɵɵdirectiveInject(SubMenuRecentlyViewedRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubMenuRecentlyViewedComponent, selectors: [["scrm-sub-menu-recently-viewed"]], inputs: { module: "module", config: "config" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function SubMenuRecentlyViewedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SubMenuRecentlyViewedComponent_ndc_dynamic_0_Template, 1, 5, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubMenuRecentlyViewedComponent, [{
        type: Component,
        args: [{ selector: 'scrm-sub-menu-recently-viewed', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'module': module, 'config': config}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: SubMenuRecentlyViewedRegistry }]; }, { module: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFavoritesComponent {
    constructor(navigation, nameMapper, configs, metadata) {
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.configs = configs;
        this.metadata = metadata;
        this.maxDisplayed = 5;
        this.subs = [];
    }
    ngOnInit() {
        const ui = this.configs.getConfigValue('ui') ?? {};
        this.maxDisplayed = parseInt(ui.navigation_max_module_favorites) ?? 5;
        this.initMetadata$();
    }
    ngOnDestroy() {
        this.clear();
    }
    ngOnChanges(changes) {
        const moduleChanges = changes?.module ?? null;
        if (moduleChanges === null) {
            return;
        }
        const previousModule = changes?.module?.previousValue ?? '';
        const currentModule = changes?.module?.currentValue ?? '';
        if (previousModule !== currentModule) {
            this.clear();
            this.initMetadata$();
        }
    }
    /**
     * Build route from recently viewed item
     * @param item
     */
    buildRoute(item) {
        const legacyName = item.attributes.parent_type ?? '';
        const module = this.nameMapper.toFrontend(legacyName) ?? '';
        const id = item.attributes.parent_id ?? '';
        return this.navigation.getRecordRouterLink(module, id);
    }
    /**
     * Init metadata subscription
     * @protected
     */
    initMetadata$() {
        const moduleMeta$ = this.metadata.allModuleMetadata$.pipe(map(value => value[this.module] ?? null));
        this.subs.push(moduleMeta$.subscribe(meta => {
            this.records = meta?.favorites ?? null;
        }));
    }
    /**
     * Clear subscription and data
     * @protected
     */
    clear() {
        this.records = null;
        this.subs.forEach(sub => sub.unsubscribe());
    }
    static { this.ɵfac = function BaseFavoritesComponent_Factory(t) { return new (t || BaseFavoritesComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseFavoritesComponent, selectors: [["ng-component"]], inputs: { module: "module" }, features: [i0.ɵɵNgOnChangesFeature], decls: 0, vars: 0, template: function BaseFavoritesComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFavoritesComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: SystemConfigStore }, { type: MetadataStore }]; }, { module: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$n = function (a0, a1, a2) { return { label: a0, url: a1, route: a2 }; };
function BaseSubMenuFavoritesComponent_ng_container_0_li_6_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 7);
    i0.ɵɵlistener("click", function BaseSubMenuFavoritesComponent_ng_container_0_li_6_Template_li_click_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r3 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r3.onItemClick($event)); })("touchstart", function BaseSubMenuFavoritesComponent_ng_container_0_li_6_Template_li_touchstart_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r5 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r5.onItemTouchStart($event)); });
    i0.ɵɵelement(1, "scrm-menu-item-link", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const favorite_r2 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap("submenu-nav-link nav-link action-link");
    i0.ɵɵproperty("link", i0.ɵɵpureFunction3(3, _c0$n, favorite_r2.attributes.parent_name, ctx_r1.buildRoute(favorite_r2), ctx_r1.buildRoute(favorite_r2)));
} }
function BaseSubMenuFavoritesComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 1)(2, "a", 2);
    i0.ɵɵlistener("touchstart", function BaseSubMenuFavoritesComponent_ng_container_0_Template_a_touchstart_2_listener($event) { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.onTouchStart($event)); })("click", function BaseSubMenuFavoritesComponent_ng_container_0_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r7); const ctx_r8 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r8.toggleDropdown()); });
    i0.ɵɵelement(3, "scrm-image", 3)(4, "scrm-label", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "ul", 5);
    i0.ɵɵtemplate(6, BaseSubMenuFavoritesComponent_ng_container_0_li_6_Template, 2, 7, "li", 6);
    i0.ɵɵpipe(7, "slice");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵclassProp("active", ctx_r0.showDropdown());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind3(7, 3, ctx_r0.records, 0, ctx_r0.maxDisplayed));
} }
class BaseSubMenuFavoritesComponent extends BaseFavoritesComponent {
    constructor(navigation, nameMapper, configs, metadata) {
        super(navigation, nameMapper, configs, metadata);
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.configs = configs;
        this.metadata = metadata;
        this.showDropdown = signal(false);
        this.clickType = 'click';
    }
    ngOnInit() {
        super.ngOnInit();
        if (this?.config?.showDropdown$) {
            this.subs.push(this.config.showDropdown$.subscribe(showDropdown => {
                this.showDropdown.set(showDropdown);
            }));
        }
    }
    toggleDropdown() {
        if (this.clickType === 'touch') {
            this.showDropdown.set(!this.showDropdown());
            this.clickType = 'click';
            this?.config?.onToggleDropdown(this.showDropdown());
            return;
        }
    }
    onTouchStart(event) {
        this.clickType = 'touch';
    }
    onItemClick($event) {
        this.toggleDropdown();
        this?.config?.onItemClick($event);
    }
    onItemTouchStart($event) {
        this.onTouchStart($event);
        this?.config?.onItemTouchStart($event);
    }
    static { this.ɵfac = function BaseSubMenuFavoritesComponent_Factory(t) { return new (t || BaseSubMenuFavoritesComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseSubMenuFavoritesComponent, selectors: [["scrm-base-sub-menu-favorites"]], inputs: { config: "config" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "nav-item", "dropdown-submenu", "submenu", "submenu-extra"], [1, "sub-nav-link", "nav-link", "action-link", "dropdown-item", "dropdown-toggle", "pr-4", 3, "touchstart", "click"], ["image", "star"], ["labelKey", "LBL_FAVORITES"], [1, "dropdown-menu", "submenu"], ["class", "nav-item", 3, "click", "touchstart", 4, "ngFor", "ngForOf"], [1, "nav-item", 3, "click", "touchstart"], [3, "link"]], template: function BaseSubMenuFavoritesComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseSubMenuFavoritesComponent_ng_container_0_Template, 8, 7, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.records && ctx.records.length);
        } }, dependencies: [i2.NgForOf, i2.NgIf, ImageComponent, LabelComponent, MenuItemLinkComponent, i2.SlicePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseSubMenuFavoritesComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-sub-menu-favorites', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"records && records.length\">\n    <li class=\"nav-item dropdown-submenu submenu submenu-extra\">\n\n        <a class=\"sub-nav-link nav-link action-link dropdown-item dropdown-toggle pr-4\"\n           (touchstart)=\"onTouchStart($event)\"\n           (click)=\"toggleDropdown()\">\n            <scrm-image image=\"star\"></scrm-image>\n            <scrm-label labelKey=\"LBL_FAVORITES\"></scrm-label>\n        </a>\n\n        <ul class=\"dropdown-menu submenu\"\n            [class.active]=\"showDropdown()\"\n        >\n            <li *ngFor=\"let favorite of records | slice:0:maxDisplayed\"\n                class=\"nav-item\"\n                (click)=\"onItemClick($event)\"\n                (touchstart)=\"onItemTouchStart($event)\"\n                >\n                <scrm-menu-item-link [class]=\"'submenu-nav-link nav-link action-link'\"\n                                     [link]=\"{\n                                                label: favorite.attributes.parent_name,\n                                                url: buildRoute(favorite),\n                                                route: buildRoute(favorite)\n                                             }\">\n                </scrm-menu-item-link>\n            </li>\n        </ul>\n    </li>\n</ng-container>\n\n\n\n" }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: SystemConfigStore }, { type: MetadataStore }]; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubMenuFavoritesRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseSubMenuFavoritesComponent);
    }
    static { this.ɵfac = function SubMenuFavoritesRegistry_Factory(t) { return new (t || SubMenuFavoritesRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubMenuFavoritesRegistry, factory: SubMenuFavoritesRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubMenuFavoritesRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$m = function (a0, a1) { return { "module": a0, "config": a1 }; };
function SubMenuFavoritesComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction2(2, _c0$m, ctx_r0.module, ctx_r0.config));
} }
class SubMenuFavoritesComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function SubMenuFavoritesComponent_Factory(t) { return new (t || SubMenuFavoritesComponent)(i0.ɵɵdirectiveInject(SubMenuFavoritesRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubMenuFavoritesComponent, selectors: [["scrm-sub-menu-favorites"]], inputs: { module: "module", config: "config" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function SubMenuFavoritesComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SubMenuFavoritesComponent_ndc_dynamic_0_Template, 1, 5, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubMenuFavoritesComponent, [{
        type: Component,
        args: [{ selector: 'scrm-sub-menu-favorites', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'module': module, 'config': config}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: SubMenuFavoritesRegistry }]; }, { module: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$l = ["topLink"];
function BaseMenuItemComponent_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseMenuItemComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseMenuItemComponent_ng_container_0_ng_container_1_Template, 1, 0, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r2 = i0.ɵɵreference(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r2);
} }
function BaseMenuItemComponent_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseMenuItemComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseMenuItemComponent_ng_container_1_ng_container_1_Template, 1, 0, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r2 = i0.ɵɵreference(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r2);
} }
function BaseMenuItemComponent_ng_template_2_div_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵelement(1, "scrm-menu-item-link", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const sub_r11 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap("sub-nav-link nav-link action-link");
    i0.ɵɵproperty("icon", sub_r11.icon)("link", sub_r11.link);
} }
function BaseMenuItemComponent_ng_template_2_div_5_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "scrm-sub-menu-recently-viewed", 13);
    i0.ɵɵlistener("click", function BaseMenuItemComponent_ng_template_2_div_5_ng_container_2_Template_scrm_sub_menu_recently_viewed_click_1_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "scrm-sub-menu-favorites", 13);
    i0.ɵɵlistener("click", function BaseMenuItemComponent_ng_template_2_div_5_ng_container_2_Template_scrm_sub_menu_favorites_click_2_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r10 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("module", ctx_r10.item.module)("config", ctx_r10.recentlyViewedConfig);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("module", ctx_r10.item.module)("config", ctx_r10.favoritesConfig);
} }
function BaseMenuItemComponent_ng_template_2_div_5_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵlistener("click", function BaseMenuItemComponent_ng_template_2_div_5_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r14.hideDropdown()); });
    i0.ɵɵtemplate(1, BaseMenuItemComponent_ng_template_2_div_5_div_1_Template, 2, 4, "div", 10);
    i0.ɵɵtemplate(2, BaseMenuItemComponent_ng_template_2_div_5_ng_container_2_Template, 3, 4, "ng-container", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("show", ctx_r8.showDropdown())("hover-enabled", ctx_r8.hoverEnabled());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r8.item.submenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.item && ctx_r8.item.module);
} }
const _c1$5 = function (a2, a3, a4) { return { "top-nav-link": true, "nav-link-nongrouped": true, "dropdown-toggle": a2, "hover-enabled": a3, "nav-link-activated": a4 }; };
function BaseMenuItemComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    const _r17 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 3, 4)(2, "span", 5, 6);
    i0.ɵɵlistener("touchstart", function BaseMenuItemComponent_ng_template_2_Template_span_touchstart_2_listener() { i0.ɵɵrestoreView(_r17); const ctx_r16 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r16.onTouchStart()); })("touchend", function BaseMenuItemComponent_ng_template_2_Template_span_touchend_2_listener() { i0.ɵɵrestoreView(_r17); const ctx_r18 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r18.onTouchEnd()); })("click", function BaseMenuItemComponent_ng_template_2_Template_span_click_2_listener($event) { i0.ɵɵrestoreView(_r17); const ctx_r19 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r19.onClick($event)); });
    i0.ɵɵelement(4, "scrm-menu-item-link", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, BaseMenuItemComponent_ng_template_2_div_5_Template, 3, 6, "div", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵclassMap(i0.ɵɵpureFunction3(5, _c1$5, ctx_r3.item.submenu.length, ctx_r3.hoverEnabled(), ctx_r3.showDropdown()));
    i0.ɵɵproperty("link", ctx_r3.item.link)("config", ctx_r3.topLinkConfig);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.item.submenu.length);
} }
class BaseMenuItemComponent {
    constructor(appStateStore, moduleNavigation) {
        this.appStateStore = appStateStore;
        this.moduleNavigation = moduleNavigation;
        this.index = 0;
        this.showDropdown = signal(false);
        this.hoverEnabled = signal(true);
        this.clickType = 'click';
        this.subs = [];
    }
    ngOnInit() {
        this.showRecentlyViewed = new Subject();
        this.showFavorites = new Subject();
        this.topLinkConfig = {
            onClick: (event) => {
            },
            onTouchStart: (event) => {
            }
        };
        this.recentlyViewedConfig = {
            onItemClick: (event) => {
                if (this.clickType === 'touch') {
                    this.hideDropdown();
                    this.clickType = 'click';
                }
            },
            onItemTouchStart: (event) => {
                this.clickType = 'touch';
            },
            onToggleDropdown: (showDropdown) => {
                if (showDropdown) {
                    this.showFavorites.next(false);
                }
            },
            showDropdown$: this.showRecentlyViewed.asObservable()
        };
        this.favoritesConfig = {
            onItemClick: (event) => {
                if (this.clickType === 'touch') {
                    this.hideDropdown();
                    this.clickType = 'click';
                }
            },
            onItemTouchStart: (event) => {
                this.clickType = 'touch';
            },
            onToggleDropdown: (showDropdown) => {
                if (showDropdown) {
                    this.showRecentlyViewed.next(false);
                }
            },
            showDropdown$: this.showFavorites.asObservable()
        };
        this.subs.push(this.appStateStore.activeNavbarDropdown$.subscribe((activeDropdown) => {
            if (this.index !== activeDropdown) {
                this.hideDropdown();
            }
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.showRecentlyViewed.unsubscribe();
        this.showFavorites.unsubscribe();
    }
    hideDropdown() {
        this.showDropdown.set(false);
        this.hoverEnabled.set(true);
    }
    navigate() {
        this.moduleNavigation.navigateUsingMenuItem(this.item);
    }
    onTopItemClick($event) {
        if (this.clickType === 'click') {
            this.appStateStore.resetActiveDropdown();
            this.navigate();
            return;
        }
        this.toggleDropdown();
        this.clickType = 'click';
    }
    toggleDropdown() {
        this.showDropdown.set(!this.showDropdown());
        if (this.showDropdown()) {
            this.appStateStore.setActiveDropdown(this.index);
            this.hoverEnabled.set(false);
        }
        else {
            this.appStateStore.resetActiveDropdown();
            this.hoverEnabled.set(true);
        }
    }
    onTouchStart() {
        this.clickType = 'touch';
    }
    onTouchEnd() {
        this.clickType = 'touch';
    }
    onClick(event) {
        event.stopImmediatePropagation();
        event.stopPropagation();
        this.onTopItemClick(event);
    }
    static { this.ɵfac = function BaseMenuItemComponent_Factory(t) { return new (t || BaseMenuItemComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(ModuleNavigation)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMenuItemComponent, selectors: [["scrm-base-menu-item"]], viewQuery: function BaseMenuItemComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$l, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.topLink = _t.first);
        } }, inputs: { item: "item", index: "index" }, decls: 4, vars: 2, consts: [[4, "ngIf"], ["menuItem", ""], [4, "ngTemplateOutlet"], [1, "menu-item-wrapper"], ["menuItemWrapper", ""], ["data-target", ".navbar-collapse", "data-toggle", "collapse", 3, "touchstart", "touchend", "click"], ["topLink", ""], [3, "link", "config"], ["aria-labelledby", "navbarDropdownMenuLink", "class", "dropdown-menu submenu", 3, "show", "hover-enabled", "click", 4, "ngIf"], ["aria-labelledby", "navbarDropdownMenuLink", 1, "dropdown-menu", "submenu", 3, "click"], ["class", "nav-item", 4, "ngFor", "ngForOf"], [1, "nav-item"], [3, "icon", "link"], [3, "module", "config", "click"]], template: function BaseMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseMenuItemComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(1, BaseMenuItemComponent_ng_container_1_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(2, BaseMenuItemComponent_ng_template_2_Template, 6, 9, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.hoverEnabled());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.hoverEnabled());
        } }, dependencies: [i2.NgForOf, i2.NgIf, i2.NgTemplateOutlet, SubMenuRecentlyViewedComponent, SubMenuFavoritesComponent, MenuItemLinkComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"hoverEnabled()\">\n    <ng-container *ngTemplateOutlet=\"menuItem\"></ng-container>\n</ng-container>\n<ng-container *ngIf=\"!hoverEnabled()\">\n    <ng-container *ngTemplateOutlet=\"menuItem\"></ng-container>\n</ng-container>\n\n<ng-template #menuItem>\n    <div class=\"menu-item-wrapper\" #menuItemWrapper>\n        <span data-target=\".navbar-collapse\" data-toggle=\"collapse\" #topLink\n              (touchstart)=\"onTouchStart()\"\n              (touchend)=\"onTouchEnd()\"\n              (click)=\"onClick($event)\"\n        >\n                <scrm-menu-item-link [class]=\"{\n                                            'top-nav-link': true,\n                                            'nav-link-nongrouped': true,\n                                            'dropdown-toggle': item.submenu.length,\n                                            'hover-enabled': hoverEnabled(),\n                                            'nav-link-activated': showDropdown()\n                                        }\"\n                                     [link]=\"item.link\"\n                                     [config]=\"this.topLinkConfig\">\n                </scrm-menu-item-link>\n        </span>\n\n        <div (click)=\"hideDropdown()\"\n             aria-labelledby=\"navbarDropdownMenuLink\"\n             *ngIf=\"item.submenu.length\"\n             class=\"dropdown-menu submenu\"\n             [class.show]=\"showDropdown()\"\n             [class.hover-enabled]=\"hoverEnabled()\">\n\n            <div *ngFor=\"let sub of item.submenu\" class=\"nav-item\">\n\n                <scrm-menu-item-link\n                        [class]=\"'sub-nav-link nav-link action-link'\"\n                        [icon]=\"sub.icon\"\n                        [link]=\"sub.link\">\n                </scrm-menu-item-link>\n\n            </div>\n\n            <ng-container *ngIf=\"item && item.module\">\n                <scrm-sub-menu-recently-viewed\n                        [module]=\"item.module\"\n                        [config]=\"recentlyViewedConfig\"\n                        (click)=\"$event.stopPropagation();\">\n\n                </scrm-sub-menu-recently-viewed>\n                <scrm-sub-menu-favorites\n                        [module]=\"item.module\"\n                        [config]=\"favoritesConfig\"\n                        (click)=\"$event.stopPropagation()\"></scrm-sub-menu-favorites>\n            </ng-container>\n        </div>\n    </div>\n</ng-template>\n" }]
    }], function () { return [{ type: AppStateStore }, { type: ModuleNavigation }]; }, { item: [{
            type: Input
        }], index: [{
            type: Input
        }], topLink: [{
            type: ViewChild,
            args: ['topLink']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MenuItemRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseMenuItemComponent);
    }
    static { this.ɵfac = function MenuItemRegistry_Factory(t) { return new (t || MenuItemRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MenuItemRegistry, factory: MenuItemRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$k = function (a0, a1) { return { "item": a0, "index": a1 }; };
function MenuItemComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction2(2, _c0$k, ctx_r0.item, ctx_r0.index));
} }
class MenuItemComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function MenuItemComponent_Factory(t) { return new (t || MenuItemComponent)(i0.ɵɵdirectiveInject(MenuItemRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MenuItemComponent, selectors: [["scrm-menu-item"]], inputs: { item: "item", index: "index" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function MenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MenuItemComponent_ndc_dynamic_0_Template, 1, 5, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'item': item, 'index': index}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: MenuItemRegistry }]; }, { item: [{
            type: Input
        }], index: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseHomeMenuItemComponent {
    constructor() {
    }
    static { this.ɵfac = function BaseHomeMenuItemComponent_Factory(t) { return new (t || BaseHomeMenuItemComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseHomeMenuItemComponent, selectors: [["scrm-base-home-menu-item"]], inputs: { route: "route", active: "active" }, decls: 4, vars: 3, consts: [[1, "navbar-nav", "home-nav"], [1, "nav-item"], [1, "home-nav-link", 3, "routerLink"], ["image", "home", 1, "home-icon"]], template: function BaseHomeMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "ul", 0)(1, "li", 1)(2, "a", 2);
            i0.ɵɵelement(3, "scrm-image", 3);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("active", ctx.active);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("routerLink", ctx.route);
        } }, dependencies: [i1$2.RouterLink, ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseHomeMenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-home-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ul class=\"navbar-nav home-nav\">\n    <li [class.active]=\"active\" class=\"nav-item\">\n        <a [routerLink]=\"route\" class=\"home-nav-link\">\n            <scrm-image class=\"home-icon\" image=\"home\"></scrm-image>\n        </a>\n    </li>\n</ul>\n" }]
    }], function () { return []; }, { route: [{
            type: Input
        }], active: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HomeMenuItemRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseHomeMenuItemComponent);
    }
    static { this.ɵfac = function HomeMenuItemRegistry_Factory(t) { return new (t || HomeMenuItemRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: HomeMenuItemRegistry, factory: HomeMenuItemRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HomeMenuItemRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$j = function (a0, a1) { return { "route": a0, "active": a1 }; };
function HomeMenuItemComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction2(2, _c0$j, ctx_r0.route, ctx_r0.active));
} }
class HomeMenuItemComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function HomeMenuItemComponent_Factory(t) { return new (t || HomeMenuItemComponent)(i0.ɵɵdirectiveInject(HomeMenuItemRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: HomeMenuItemComponent, selectors: [["scrm-home-menu-item"]], inputs: { route: "route", active: "active" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function HomeMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, HomeMenuItemComponent_ndc_dynamic_0_Template, 1, 5, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HomeMenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-home-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'route': route, 'active': active}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: HomeMenuItemRegistry }]; }, { route: [{
            type: Input
        }], active: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function BaseGroupedMenuItemComponent_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseGroupedMenuItemComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseGroupedMenuItemComponent_ng_container_0_ng_container_1_Template, 1, 0, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r2 = i0.ɵɵreference(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r2);
} }
function BaseGroupedMenuItemComponent_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseGroupedMenuItemComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseGroupedMenuItemComponent_ng_container_1_ng_container_1_Template, 1, 0, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵnextContext();
    const _r2 = i0.ɵɵreference(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r2);
} }
function BaseGroupedMenuItemComponent_ng_template_2_span_1_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "span", 7);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_span_1_Template_span_click_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.toggleDropdown()); });
    i0.ɵɵelementStart(1, "a", 8);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "truncate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("hover-enabled", ctx_r6.hoverEnabled());
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(3, 3, ctx_r6.item.link.label, ctx_r6.charSize.minLength), " ");
} }
const _c0$i = function (a2, a3, a4) { return { "top-nav-link": true, "nav-link-grouped": true, "dropdown-toggle": a2, "hover-enabled": a3, "nav-link-activated": a4 }; };
function BaseGroupedMenuItemComponent_ng_template_2_span_2_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "span", 7);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_span_2_Template_span_click_0_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r11.toggleDropdown()); });
    i0.ɵɵelementStart(1, "li", 9);
    i0.ɵɵelement(2, "scrm-menu-item-link", 10);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵclassMap(i0.ɵɵpureFunction3(3, _c0$i, ctx_r7.item.submenu.length, ctx_r7.hoverEnabled(), ctx_r7.showDropdown()));
    i0.ɵɵproperty("link", ctx_r7.item.link);
} }
function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_li_1_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 16)(1, "scrm-menu-item-link", 17);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_li_1_Template_scrm_menu_item_link_click_1_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r19.hideDropdown()); });
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const subitem_r18 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap("submenu-nav-link nav-link action-link");
    i0.ɵɵproperty("icon", subitem_r18.icon)("link", subitem_r18.link);
} }
function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "scrm-sub-menu-recently-viewed", 18);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_ng_container_2_Template_scrm_sub_menu_recently_viewed_click_1_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "scrm-sub-menu-favorites", 18);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_ng_container_2_Template_scrm_sub_menu_favorites_click_2_listener($event) { return $event.stopPropagation(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const sub_r13 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r17 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("module", sub_r13.module)("config", ctx_r17.recentlyViewedConfig);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("module", sub_r13.module)("config", ctx_r17.favoritesConfig);
} }
function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_Template(rf, ctx) { if (rf & 1) {
    const _r25 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ul", 14);
    i0.ɵɵlistener("click", function BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_Template_ul_click_0_listener() { i0.ɵɵrestoreView(_r25); const ctx_r24 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r24.hideDropdown()); });
    i0.ɵɵtemplate(1, BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_li_1_Template, 2, 4, "li", 15);
    i0.ɵɵtemplate(2, BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_ng_container_2_Template, 3, 4, "ng-container", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r26 = i0.ɵɵnextContext();
    const sub_r13 = ctx_r26.$implicit;
    const i_r14 = ctx_r26.index;
    const ctx_r15 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("rounded-0", sub_r13.submenu && sub_r13.submenu.length === 1)("active", ctx_r15.showSubDropdown[i_r14]());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", sub_r13.submenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", sub_r13 && sub_r13.module);
} }
const _c1$4 = function (a3, a4) { return { "sub-nav-link": true, "nav-link": true, "action-link": true, "dropdown-item": a3, "dropdown-toggle": a4 }; };
function BaseGroupedMenuItemComponent_ng_template_2_li_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 11);
    i0.ɵɵelement(1, "scrm-menu-item-link", 12);
    i0.ɵɵtemplate(2, BaseGroupedMenuItemComponent_ng_template_2_li_4_ul_2_Template, 3, 6, "ul", 13);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const sub_r13 = ctx.$implicit;
    const i_r14 = ctx.index;
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap(i0.ɵɵpureFunction2(5, _c1$4, sub_r13.submenu.length, sub_r13.submenu.length));
    i0.ɵɵproperty("link", sub_r13.link)("config", ctx_r8.getConfig(sub_r13, i_r14));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", sub_r13.submenu.length);
} }
function BaseGroupedMenuItemComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, BaseGroupedMenuItemComponent_ng_template_2_span_1_Template, 4, 6, "span", 4);
    i0.ɵɵtemplate(2, BaseGroupedMenuItemComponent_ng_template_2_span_2_Template, 3, 7, "span", 4);
    i0.ɵɵelementStart(3, "ul", 5);
    i0.ɵɵtemplate(4, BaseGroupedMenuItemComponent_ng_template_2_li_4_Template, 3, 8, "li", 6);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r3.item.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.item.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("show", ctx_r3.showDropdown())("hover-enabled", ctx_r3.hoverEnabled())("mobile-admin-dropdown", ctx_r3.item.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r3.item.submenu);
} }
class BaseGroupedMenuItemComponent {
    constructor(appStateStore, moduleNavigation, systemConfigStore) {
        this.appStateStore = appStateStore;
        this.moduleNavigation = moduleNavigation;
        this.systemConfigStore = systemConfigStore;
        this.index = 0;
        this.showDropdown = signal(false);
        this.showSubDropdown = [];
        this.hoverEnabled = signal(true);
        this.subs = [];
        this.clickType = 'click';
        this.openSubDropdown = null;
        this.charSize = {
            minLength: 20,
            mediumLength: 20,
            maxLength: 20
        };
    }
    ngOnInit() {
        this.showRecentlyViewed = new Subject();
        this.showFavorites = new Subject();
        const characterSizes = this.systemConfigStore.getUi('navbar_truncate_character_sizes');
        this.charSize = { ...characterSizes };
        this.subs.push(this.appStateStore.activeNavbarDropdown$.subscribe((activeDropdown) => {
            if (this.index !== activeDropdown) {
                this.hideDropdown();
            }
        }));
        const submenuItems = this?.item?.submenu ?? [];
        submenuItems.forEach(() => {
            this.showSubDropdown.push(signal(false));
        });
        this.recentlyViewedConfig = {
            onItemClick: (event) => {
                if (this.clickType === 'touch') {
                    this.hideDropdown();
                    this.clickType = 'click';
                }
            },
            onItemTouchStart: (event) => {
                this.clickType = 'touch';
            },
            onToggleDropdown: (showDropdown) => {
                if (showDropdown) {
                    this.showFavorites.next(false);
                }
            },
            showDropdown$: this.showRecentlyViewed.asObservable()
        };
        this.favoritesConfig = {
            onItemClick: (event) => {
                if (this.clickType === 'touch') {
                    this.hideDropdown();
                    this.clickType = 'click';
                }
            },
            onItemTouchStart: (event) => {
                this.clickType = 'touch';
            },
            onToggleDropdown: (showDropdown) => {
                if (showDropdown) {
                    this.showRecentlyViewed.next(false);
                }
            },
            showDropdown$: this.showFavorites.asObservable()
        };
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.showRecentlyViewed.unsubscribe();
        this.showFavorites.unsubscribe();
    }
    hideDropdown() {
        this.showDropdown.set(false);
        this.hoverEnabled.set(true);
        this.showSubDropdown.forEach(subDropdown => {
            subDropdown.set(false);
        });
    }
    toggleDropdown() {
        this.showDropdown.set(!this.showDropdown());
        if (this.showDropdown()) {
            this.appStateStore.setActiveDropdown(this.index);
            this.hoverEnabled.set(false);
        }
        else {
            this.appStateStore.resetActiveDropdown();
            this.hideDropdown();
        }
    }
    navigate() {
        this.moduleNavigation.navigateUsingMenuItem(this.item);
    }
    onSubItemClick($event, item, index) {
        if (this.clickType === 'click') {
            this.navigate();
            return;
        }
        this.toggleSubDropdown(index);
        this.clickType = 'click';
    }
    toggleSubDropdown(index) {
        const openSubDropdownIndex = this.openSubDropdown ?? -1;
        if (index !== openSubDropdownIndex && openSubDropdownIndex >= 0) {
            this?.showSubDropdown[openSubDropdownIndex]?.set(false);
        }
        this.showSubDropdown[index]?.set(!this.showSubDropdown[index]());
        this.openSubDropdown = index;
        if (!this.showSubDropdown[index]()) {
            this.openSubDropdown = null;
        }
    }
    getConfig(sub, index) {
        return {
            onClick: (event) => {
                this.onSubItemClick(event, sub, index);
            },
            onTouchStart: (event) => {
                this.clickType = 'touch';
            }
        };
    }
    static { this.ɵfac = function BaseGroupedMenuItemComponent_Factory(t) { return new (t || BaseGroupedMenuItemComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseGroupedMenuItemComponent, selectors: [["scrm-base-grouped-menu-item"]], inputs: { item: "item", subNavCollapse: "subNavCollapse", index: "index" }, decls: 4, vars: 2, consts: [[4, "ngIf"], ["groupedMenuItem", ""], [4, "ngTemplateOutlet"], [1, "menu-item-wrapper"], ["data-target", ".navbar-collapse", "data-toggle", "collapse", 3, "click", 4, "ngIf"], ["aria-labelledby", "navbarDropdownMenuLink", 1, "dropdown-menu", "main"], ["class", "nav-item dropdown-submenu submenu", 4, "ngFor", "ngForOf"], ["data-target", ".navbar-collapse", "data-toggle", "collapse", 3, "click"], ["data-toggle", "dropdown", 1, "top-nav-link", "nav-link-grouped", "dropdown-toggle", "active"], [1, "nav-item", "active"], [3, "link"], [1, "nav-item", "dropdown-submenu", "submenu"], [3, "link", "config"], ["class", "dropdown-menu submenu", 3, "rounded-0", "active", "click", 4, "ngIf"], [1, "dropdown-menu", "submenu", 3, "click"], ["class", "nav-item", 4, "ngFor", "ngForOf"], [1, "nav-item"], [3, "icon", "link", "click"], [3, "module", "config", "click"]], template: function BaseGroupedMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseGroupedMenuItemComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(1, BaseGroupedMenuItemComponent_ng_container_1_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(2, BaseGroupedMenuItemComponent_ng_template_2_Template, 5, 9, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.hoverEnabled());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.hoverEnabled());
        } }, dependencies: [i2.NgForOf, i2.NgIf, i2.NgTemplateOutlet, SubMenuRecentlyViewedComponent, SubMenuFavoritesComponent, MenuItemLinkComponent, TruncatePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseGroupedMenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-grouped-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"hoverEnabled()\">\n    <ng-container *ngTemplateOutlet=\"groupedMenuItem\"></ng-container>\n</ng-container>\n<ng-container *ngIf=\"!hoverEnabled()\">\n    <ng-container *ngTemplateOutlet=\"groupedMenuItem\"></ng-container>\n</ng-container>\n\n\n<ng-template #groupedMenuItem>\n    <div class=\"menu-item-wrapper\">\n        <span data-target=\".navbar-collapse\" data-toggle=\"collapse\" *ngIf=\"!item.isGroupedMenu\"\n          (click)=\"toggleDropdown()\">\n            <a class=\"top-nav-link nav-link-grouped dropdown-toggle active\"\n               data-toggle=\"dropdown\" [class.hover-enabled]=\"hoverEnabled()\">\n                {{ item.link.label | truncate: charSize.minLength }}\n            </a>\n        </span>\n\n        <span data-target=\".navbar-collapse\" data-toggle=\"collapse\" *ngIf=\"item.isGroupedMenu\"\n              (click)=\"toggleDropdown()\">\n            <li class=\"nav-item active\">\n                <scrm-menu-item-link [class]=\"{\n                                            'top-nav-link': true,\n                                            'nav-link-grouped': true,\n                                            'dropdown-toggle': item.submenu.length,\n                                            'hover-enabled': hoverEnabled(),\n                                            'nav-link-activated': showDropdown()\n                                        }\"\n                                     [link]=\"item.link\">\n                </scrm-menu-item-link>\n            </li>\n        </span>\n        <ul aria-labelledby=\"navbarDropdownMenuLink\"\n            class=\"dropdown-menu main\"\n            [class.show]=\"showDropdown()\"\n            [class.hover-enabled]=\"hoverEnabled()\"\n            [class.mobile-admin-dropdown]=\"item.isGroupedMenu\"\n        >\n            <li *ngFor=\"let sub of item.submenu; index as i;\" class=\"nav-item dropdown-submenu submenu\">\n\n                <scrm-menu-item-link [class]=\"{\n                                        'sub-nav-link': true,\n                                        'nav-link': true,\n                                        'action-link': true,\n                                        'dropdown-item': sub.submenu.length,\n                                        'dropdown-toggle': sub.submenu.length,\n                                      }\"\n                                     [link]=\"sub.link\"\n                                     [config]=\"getConfig(sub, i)\"\n                >\n                </scrm-menu-item-link>\n\n                <ul *ngIf=\"sub.submenu.length\"\n                    (click)=\"hideDropdown()\"\n                    [class.rounded-0]=\"sub.submenu && sub.submenu.length === 1\"\n                    [class.active]=\"this.showSubDropdown[i]()\"\n                    class=\"dropdown-menu submenu\"\n                >\n\n                    <li *ngFor=\"let subitem of sub.submenu\" class=\"nav-item\">\n\n                        <scrm-menu-item-link (click)=\"hideDropdown()\"\n                                             [class]=\"'submenu-nav-link nav-link action-link'\"\n                                             [icon]=\"subitem.icon\"\n                                             [link]=\"subitem.link\">\n                        </scrm-menu-item-link>\n                    </li>\n                    <ng-container *ngIf=\"sub && sub.module\">\n                        <scrm-sub-menu-recently-viewed [module]=\"sub.module\"\n                                                       [config]=\"recentlyViewedConfig\"\n                                                       (click)=\"$event.stopPropagation();\" >\n                        </scrm-sub-menu-recently-viewed>\n                        <scrm-sub-menu-favorites [module]=\"sub.module\"\n                                                 [config]=\"favoritesConfig\"\n                                                 (click)=\"$event.stopPropagation()\">\n                        </scrm-sub-menu-favorites>\n                    </ng-container>\n                </ul>\n            </li>\n        </ul>\n    </div>\n</ng-template>\n" }]
    }], function () { return [{ type: AppStateStore }, { type: ModuleNavigation }, { type: SystemConfigStore }]; }, { item: [{
            type: Input
        }], subNavCollapse: [{
            type: Input
        }], index: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class GroupedMenuItemRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseGroupedMenuItemComponent);
    }
    static { this.ɵfac = function GroupedMenuItemRegistry_Factory(t) { return new (t || GroupedMenuItemRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GroupedMenuItemRegistry, factory: GroupedMenuItemRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupedMenuItemRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$h = function (a0, a1, a2) { return { "item": a0, "subNavCollapse": a1, "index": a2 }; };
function GroupedMenuItemComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction3(2, _c0$h, ctx_r0.item, ctx_r0.subNavCollapse, ctx_r0.index));
} }
class GroupedMenuItemComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function GroupedMenuItemComponent_Factory(t) { return new (t || GroupedMenuItemComponent)(i0.ɵɵdirectiveInject(GroupedMenuItemRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GroupedMenuItemComponent, selectors: [["scrm-grouped-menu-item"]], inputs: { item: "item", subNavCollapse: "subNavCollapse", index: "index" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function GroupedMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, GroupedMenuItemComponent_ndc_dynamic_0_Template, 1, 6, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GroupedMenuItemComponent, [{
        type: Component,
        args: [{ selector: 'scrm-grouped-menu-item', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'item': item, 'subNavCollapse': subNavCollapse, 'index': index}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: GroupedMenuItemRegistry }]; }, { item: [{
            type: Input
        }], subNavCollapse: [{
            type: Input
        }], index: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$g = function (a1) { return { "hover-enabled": true, "nav-link-activated": a1 }; };
function BaseMenuItemsListComponent_ul_0_a_2_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 6);
    i0.ɵɵlistener("click", function BaseMenuItemsListComponent_ul_0_a_2_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r4 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r4.toggleDropdown()); });
    i0.ɵɵelement(1, "scrm-label", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵclassMap(i0.ɵɵpureFunction1(3, _c0$g, ctx_r1.showDropdown()));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r1.labelKey);
} }
const _c1$3 = function (a1) { return { "hover-enabled": false, "nav-link-activated": a1 }; };
function BaseMenuItemsListComponent_ul_0_a_3_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 6);
    i0.ɵɵlistener("click", function BaseMenuItemsListComponent_ul_0_a_3_Template_a_click_0_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r6.toggleDropdown()); });
    i0.ɵɵelement(1, "scrm-label", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵclassMap(i0.ɵɵpureFunction1(3, _c1$3, ctx_r2.showDropdown()));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r2.labelKey);
} }
function BaseMenuItemsListComponent_ul_0_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "scrm-menu-item-link", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r8 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵclassMap("nav-link action-link");
    i0.ɵɵproperty("link", item_r8.link);
} }
function BaseMenuItemsListComponent_ul_0_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "ul", 1)(1, "li", 2);
    i0.ɵɵtemplate(2, BaseMenuItemsListComponent_ul_0_a_2_Template, 2, 5, "a", 3);
    i0.ɵɵtemplate(3, BaseMenuItemsListComponent_ul_0_a_3_Template, 2, 5, "a", 3);
    i0.ɵɵelementStart(4, "div", 4);
    i0.ɵɵlistener("click", function BaseMenuItemsListComponent_ul_0_Template_div_click_4_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r9.hideDropdown()); });
    i0.ɵɵtemplate(5, BaseMenuItemsListComponent_ul_0_div_5_Template, 2, 3, "div", 5);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.hoverEnabled());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.hoverEnabled());
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("show", ctx_r0.showDropdown())("hover-enabled", ctx_r0.hoverEnabled());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r0.items);
} }
class BaseMenuItemsListComponent {
    constructor(appStateStore) {
        this.appStateStore = appStateStore;
        this.showDropdown = signal(true);
        this.hoverEnabled = signal(true);
        this.allowHover = signal(true);
        this.isTouchDevice = signal(false);
        this.subs = [];
    }
    ngOnInit() {
        this.subs.push(this.appStateStore.activeNavbarDropdown$.subscribe((activeDropdown) => {
            if (this.index !== activeDropdown) {
                this.hideDropdown();
            }
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    hideDropdown() {
        this.showDropdown.set(false);
        this.hoverEnabled.set(true);
    }
    toggleDropdown() {
        this.showDropdown.set(!this.showDropdown());
        if (this.showDropdown()) {
            this.appStateStore.setActiveDropdown(this.index);
            this.hoverEnabled.set(false);
        }
        else {
            this.appStateStore.resetActiveDropdown();
            this.hoverEnabled.set(true);
        }
    }
    static { this.ɵfac = function BaseMenuItemsListComponent_Factory(t) { return new (t || BaseMenuItemsListComponent)(i0.ɵɵdirectiveInject(AppStateStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMenuItemsListComponent, selectors: [["scrm-base-menu-items-list"]], inputs: { items: "items", labelKey: "labelKey", index: "index" }, decls: 1, vars: 1, consts: [["class", "navbar-list navbar-nav nav-collapsed-items", 4, "ngIf"], [1, "navbar-list", "navbar-nav", "nav-collapsed-items"], [1, "top-nav", "nav-item", "dropdown", "non-grouped"], ["class", "nav-link-nongrouped dropdown-toggle", 3, "class", "click", 4, "ngIf"], ["aria-labelledby", "navbarDropdownMenuLink", 1, "dropdown-menu", "more-menu", "submenu", 3, "click"], ["class", "nav-item", 4, "ngFor", "ngForOf"], [1, "nav-link-nongrouped", "dropdown-toggle", 3, "click"], [3, "labelKey"], [1, "nav-item"], [3, "link"]], template: function BaseMenuItemsListComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseMenuItemsListComponent_ul_0_Template, 6, 7, "ul", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.items && ctx.items.length > 0);
        } }, dependencies: [i2.NgForOf, i2.NgIf, LabelComponent, MenuItemLinkComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMenuItemsListComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-menu-items-list', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ul *ngIf=\"items && items.length > 0\" class=\"navbar-list navbar-nav nav-collapsed-items\">\n\n    <li class=\"top-nav nav-item dropdown non-grouped\">\n\n        <a class=\"nav-link-nongrouped dropdown-toggle\" *ngIf=\"hoverEnabled()\"\n           [class]=\"{\n               'hover-enabled': true,\n               'nav-link-activated': showDropdown()\n           }\"\n           (click)=\"toggleDropdown()\">\n            <scrm-label [labelKey]=\"labelKey\"></scrm-label>\n        </a>\n\n        <a class=\"nav-link-nongrouped dropdown-toggle\" *ngIf=\"!hoverEnabled()\"\n           [class]=\"{\n               'hover-enabled':false,\n               'nav-link-activated': showDropdown()\n           }\"\n           (click)=\"toggleDropdown()\">\n            <scrm-label [labelKey]=\"labelKey\"></scrm-label>\n        </a>\n\n        <div aria-labelledby=\"navbarDropdownMenuLink\"\n             (click)=\"hideDropdown()\"\n             class=\"dropdown-menu more-menu submenu\"\n             [class.show]=\"showDropdown()\"\n             [class.hover-enabled]=\"hoverEnabled()\"\n        >\n            <div *ngFor=\"let item of items\" class=\"nav-item\">\n                <scrm-menu-item-link [class]=\"'nav-link action-link'\" [link]=\"item.link\">\n                </scrm-menu-item-link>\n            </div>\n        </div>\n    </li>\n</ul>\n\n" }]
    }], function () { return [{ type: AppStateStore }]; }, { items: [{
            type: Input
        }], labelKey: [{
            type: Input
        }], index: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MenuItemsListRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseMenuItemsListComponent);
    }
    static { this.ɵfac = function MenuItemsListRegistry_Factory(t) { return new (t || MenuItemsListRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MenuItemsListRegistry, factory: MenuItemsListRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemsListRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$f = function (a0, a1, a2) { return { "items": a0, "labelKey": a1, "index": a2 }; };
function MenuItemsListComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction3(2, _c0$f, ctx_r0.items, ctx_r0.labelKey, ctx_r0.index));
} }
class MenuItemsListComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function MenuItemsListComponent_Factory(t) { return new (t || MenuItemsListComponent)(i0.ɵɵdirectiveInject(MenuItemsListRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MenuItemsListComponent, selectors: [["scrm-menu-items-list"]], inputs: { items: "items", labelKey: "labelKey", index: "index" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function MenuItemsListComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MenuItemsListComponent_ndc_dynamic_0_Template, 1, 6, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuItemsListComponent, [{
        type: Component,
        args: [{ selector: 'scrm-menu-items-list', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'items': items, 'labelKey': labelKey, 'index': index}\">\n</ndc-dynamic>\n\n" }]
    }], function () { return [{ type: MenuItemsListRegistry }]; }, { items: [{
            type: Input
        }], labelKey: [{
            type: Input
        }], index: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$e = ["mobileGlobalLinkTitle"];
const _c1$2 = ["searchTerm"];
const _c2 = ["alertDropdown"];
function BaseNavbarComponent_div_0_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "nav", 5)(1, "div", 6)(2, "ul", 7)(3, "li", 8);
    i0.ɵɵtext(4, "\u00A0 ");
    i0.ɵɵelementEnd()()()();
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "nav", 9)(2, "div", 10)(3, "ul", 7)(4, "li", 11);
    i0.ɵɵelement(5, "scrm-logo-ui");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementContainerEnd();
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_li_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 29);
    i0.ɵɵelement(1, "scrm-menu-item", 30);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", ctx_r9.navbar.current);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_li_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 31);
    i0.ɵɵelement(1, "scrm-grouped-menu-item", 32);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r10 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", ctx_r10.navbar.current)("subNavCollapse", ctx_r10.subNavCollapse);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_container_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_ng_container_0_hr_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "hr");
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 34);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_ng_container_0_hr_3_Template, 1, 0, "hr", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const globalAction_r15 = ctx.$implicit;
    const first_r16 = ctx.first;
    const last_r17 = ctx.last;
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("href", globalAction_r15.link.url, i0.ɵɵsanitizeUrl);
    i0.ɵɵpropertyInterpolate("target", globalAction_r15.link.target);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1("", globalAction_r15.link.label, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", last_r17 === true || first_r16 === true);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_ng_container_0_Template, 4, 4, "ng-container", 33);
} if (rf & 2) {
    const ctx_r13 = i0.ɵɵnextContext(4);
    i0.ɵɵproperty("ngForOf", ctx_r13.navbar.globalActions);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "ul", 12)(2, "div", 13)(3, "button", 14);
    i0.ɵɵlistener("click", function BaseNavbarComponent_div_0_ng_container_2_ng_container_2_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r19.toggleSidebar()); });
    i0.ɵɵelement(4, "scrm-image", 15);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "nav", 16)(6, "ul", 17);
    i0.ɵɵtemplate(7, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_li_7_Template, 2, 1, "li", 18);
    i0.ɵɵtemplate(8, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_li_8_Template, 2, 2, "li", 19);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(9, "div", 20);
    i0.ɵɵtemplate(10, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_container_10_Template, 1, 0, "ng-container", 21);
    i0.ɵɵelementStart(11, "div", 22)(12, "li", 23)(13, "a", 24, 25);
    i0.ɵɵelement(15, "scrm-image", 26);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(16, "div", 27)(17, "span", 28);
    i0.ɵɵtext(18);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(19, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_ng_template_19_Template, 1, 1, "ng-template", 2);
    i0.ɵɵelement(20, "scrm-logout-ui");
    i0.ɵɵelementEnd()()()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const _r12 = i0.ɵɵreference(14);
    i0.ɵɵnextContext(2);
    const _r4 = i0.ɵɵreference(4);
    const ctx_r7 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngClass", ctx_r7.isSmallScreen() && ctx_r7.isSearchBoxVisible() ? "d-none" : "d-block");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r7.navbar.current && !ctx_r7.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (ctx_r7.navbar.current == null ? null : ctx_r7.navbar.current.submenu) && ctx_r7.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", _r4);
    i0.ɵɵadvance(6);
    i0.ɵɵstyleProp("min-width", _r12.offsetWidth, "px");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate2("", ctx_r7.navbar.currentUser.firstName, " ", ctx_r7.navbar.currentUser.lastName, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.navbar.globalActions);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 44);
    i0.ɵɵelement(2, "scrm-grouped-menu-item", 45);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r25 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("item", ctx_r25.navbar.current)("subNavCollapse", ctx_r25.subNavCollapse)("index", 1);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_li_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 46);
    i0.ɵɵelement(1, "scrm-menu-item", 47);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r26 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", ctx_r26.navbar.current)("index", 1);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_li_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 44);
    i0.ɵɵelement(1, "scrm-grouped-menu-item", 45);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r28 = ctx.$implicit;
    const i_r29 = ctx.index;
    const ctx_r27 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", item_r28)("subNavCollapse", ctx_r27.subNavCollapse)("index", i_r29 + 2);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "ul", 40);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_ng_container_2_Template, 3, 3, "ng-container", 3);
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_li_3_Template, 2, 2, "li", 41);
    i0.ɵɵtemplate(4, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_li_4_Template, 2, 3, "li", 42);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(5, "scrm-menu-items-list", 43);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r21 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r21.navbar.current && ctx_r21.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r21.navbar.current && !ctx_r21.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r21.navbar.menu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("items", ctx_r21.navbar.all.modules)("index", ctx_r21.navbar.menu.length + 2);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_li_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 46);
    i0.ɵɵelement(1, "scrm-menu-item", 47);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r30 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", ctx_r30.navbar.current)("index", 1);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 44);
    i0.ɵɵelement(2, "scrm-grouped-menu-item", 45);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r31 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("item", ctx_r31.navbar.current)("subNavCollapse", ctx_r31.subNavCollapse)("index", 1);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_li_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 50);
    i0.ɵɵelement(1, "scrm-menu-item", 47);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r33 = ctx.$implicit;
    const i_r34 = ctx.index;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("item", item_r33)("index", i_r34 + 2);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "ul", 7);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_li_2_Template, 2, 2, "li", 41);
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_ng_container_3_Template, 3, 3, "ng-container", 3);
    i0.ɵɵtemplate(4, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_li_4_Template, 2, 2, "li", 48);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(5, "scrm-menu-items-list", 49);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r22 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r22.navbar.current && !ctx_r22.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (ctx_r22.navbar.current == null ? null : ctx_r22.navbar.current.submenu) && ctx_r22.navbar.current.isGroupedMenu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r22.navbar.menu);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("items", ctx_r22.navbar.all.modules)("index", ctx_r22.navbar.menu.length + 2);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_ng_container_1_hr_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "hr");
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 34);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_ng_container_1_hr_3_Template, 1, 0, "hr", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const globalAction_r36 = ctx.$implicit;
    const first_r37 = ctx.first;
    const last_r38 = ctx.last;
    i0.ɵɵadvance(1);
    i0.ɵɵpropertyInterpolate("href", globalAction_r36.link.url, i0.ɵɵsanitizeUrl);
    i0.ɵɵpropertyInterpolate("target", globalAction_r36.link.target);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1("", globalAction_r36.link.label, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", last_r38 === true || first_r37 === true);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_ng_container_1_Template, 4, 4, "ng-container", 33);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r24 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r24.navbar.globalActions);
} }
function BaseNavbarComponent_div_0_ng_container_2_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "nav", 35)(2, "div", 36);
    i0.ɵɵelement(3, "scrm-home-menu-item", 37);
    i0.ɵɵtemplate(4, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_4_Template, 6, 5, "ng-container", 3);
    i0.ɵɵtemplate(5, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_5_Template, 6, 5, "ng-container", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(6, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_6_Template, 1, 0, "ng-container", 21);
    i0.ɵɵelementStart(7, "div", 22)(8, "ul", 7)(9, "li", 23)(10, "a", 38);
    i0.ɵɵelement(11, "scrm-image", 26);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "div", 39)(13, "span", 28);
    i0.ɵɵtext(14);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(15, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_ng_container_15_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelement(16, "scrm-logout-ui");
    i0.ɵɵelementEnd()()()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    const _r4 = i0.ɵɵreference(4);
    const ctx_r8 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngbCollapse", ctx_r8.mainNavCollapse);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("active", vm_r1.appState.module && vm_r1.appState.module === "home")("route", ctx_r8.getHomePage());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.userPreferences["navigation_paradigm"] == "gm");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.userPreferences["navigation_paradigm"] != "gm");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", _r4);
    i0.ɵɵadvance(8);
    i0.ɵɵtextInterpolate2("", ctx_r8.navbar.currentUser.firstName, " ", ctx_r8.navbar.currentUser.lastName, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.navbar.globalActions);
} }
function BaseNavbarComponent_div_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_container_2_ng_container_1_Template, 6, 0, "ng-container", 3);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_container_2_ng_container_2_Template, 21, 9, "ng-container", 3);
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_container_2_ng_container_3_Template, 17, 9, "ng-container", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r3.isUserLoggedIn);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.isUserLoggedIn && ctx_r3.mobileNavbar);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.isUserLoggedIn && !ctx_r3.mobileNavbar);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 73);
    i0.ɵɵelement(2, "scrm-label", 74);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const moduleQuickAction_r46 = i0.ɵɵnextContext().$implicit;
    const ctx_r47 = i0.ɵɵnextContext(4);
    let tmp_1_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", moduleQuickAction_r46.url)("queryParams", (tmp_1_0 = moduleQuickAction_r46 == null ? null : moduleQuickAction_r46.params) !== null && tmp_1_0 !== undefined ? tmp_1_0 : null);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", moduleQuickAction_r46.labelKey)("module", ctx_r47.navbar.current.module);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r52 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 75);
    i0.ɵɵlistener("click", function BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_ng_container_2_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r52); const moduleQuickAction_r46 = i0.ɵɵnextContext().$implicit; const ctx_r50 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r50.handleProcess(moduleQuickAction_r46)); });
    i0.ɵɵelement(2, "scrm-label", 74);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const moduleQuickAction_r46 = i0.ɵɵnextContext().$implicit;
    const ctx_r48 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", moduleQuickAction_r46.labelKey)("module", ctx_r48.navbar.current.module);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 72);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_ng_container_1_Template, 3, 4, "ng-container", 3);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_ng_container_2_Template, 3, 2, "ng-container", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const moduleQuickAction_r46 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !moduleQuickAction_r46.process);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", moduleQuickAction_r46.process);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 69);
    i0.ɵɵelement(2, "scrm-label", 70);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_template_3_ng_container_7_li_3_Template, 3, 2, "li", 71);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r41 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("module", ctx_r41.navbar.current.module);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r41.currentQuickActions);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 73);
    i0.ɵɵelement(2, "scrm-label", 74);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const quickAction_r55 = i0.ɵɵnextContext().$implicit;
    let tmp_1_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", quickAction_r55.url)("queryParams", (tmp_1_0 = quickAction_r55 == null ? null : quickAction_r55.params) !== null && tmp_1_0 !== undefined ? tmp_1_0 : null);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", quickAction_r55.labelKey)("module", quickAction_r55.module);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r61 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 75);
    i0.ɵɵlistener("click", function BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_ng_container_2_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r61); const quickAction_r55 = i0.ɵɵnextContext().$implicit; const ctx_r59 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r59.handleProcess(quickAction_r55)); });
    i0.ɵɵelement(2, "scrm-label", 74);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const quickAction_r55 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", quickAction_r55.labelKey)("module", quickAction_r55.module);
} }
function BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 72);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_ng_container_1_Template, 3, 4, "ng-container", 3);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_ng_container_2_Template, 3, 2, "ng-container", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const quickAction_r55 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !quickAction_r55.process);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", quickAction_r55.process);
} }
const _c3 = function () { return []; };
function BaseNavbarComponent_div_0_ng_template_3_ng_container_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "li", 69);
    i0.ɵɵelement(2, "scrm-label", 76);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_template_3_ng_container_8_li_3_Template, 3, 2, "li", 71);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r42 = i0.ɵɵnextContext(3);
    let tmp_0_0;
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngForOf", (tmp_0_0 = ctx_r42 == null ? null : ctx_r42.navigation == null ? null : ctx_r42.navigation.quickActions) !== null && tmp_0_0 !== undefined ? tmp_0_0 : i0.ɵɵpureFunction0(1, _c3));
} }
function BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_span_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const notificationCount_r65 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(notificationCount_r65);
} }
function BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 83);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_span_1_ng_container_1_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const notificationCount_r65 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", notificationCount_r65 > 0);
} }
function BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_span_1_Template, 2, 1, "span", 82);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const notificationCount_r65 = ctx.ngIf;
    let tmp_0_0;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", (tmp_0_0 = notificationCount_r65) !== null && tmp_0_0 !== undefined ? tmp_0_0 : false);
} }
function BaseNavbarComponent_div_0_ng_template_3_div_24_Template(rf, ctx) { if (rf & 1) {
    const _r71 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 77, 78)(2, "ul", 53)(3, "li", 23)(4, "a", 79);
    i0.ɵɵlistener("mouseenter", function BaseNavbarComponent_div_0_ng_template_3_div_24_Template_a_mouseenter_4_listener() { i0.ɵɵrestoreView(_r71); const ctx_r70 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r70.markAsRead()); });
    i0.ɵɵelement(5, "scrm-image", 80);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(6, BaseNavbarComponent_div_0_ng_template_3_div_24_ng_container_6_Template, 2, 1, "ng-container", 3);
    i0.ɵɵpipe(7, "async");
    i0.ɵɵelementStart(8, "div", 81);
    i0.ɵɵlistener("click", function BaseNavbarComponent_div_0_ng_template_3_div_24_Template_div_click_8_listener() { i0.ɵɵrestoreView(_r71); const ctx_r72 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r72.closeNotificationMenu()); });
    i0.ɵɵelement(9, "scrm-notifications");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const ctx_r44 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(7, 1, ctx_r44.notificationCount$));
} }
function BaseNavbarComponent_div_0_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    const _r74 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 51)(1, "div", 52)(2, "ul", 53)(3, "li", 23)(4, "a", 54);
    i0.ɵɵelement(5, "scrm-image", 55);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "ul", 56);
    i0.ɵɵtemplate(7, BaseNavbarComponent_div_0_ng_template_3_ng_container_7_Template, 4, 2, "ng-container", 3);
    i0.ɵɵtemplate(8, BaseNavbarComponent_div_0_ng_template_3_ng_container_8_Template, 4, 2, "ng-container", 3);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(9, "div", 57)(10, "ul", 53)(11, "li", 23)(12, "a", 58);
    i0.ɵɵelement(13, "scrm-image", 59);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(14, "div", 60);
    i0.ɵɵelement(15, "scrm-recently-viewed", 61);
    i0.ɵɵpipe(16, "slice");
    i0.ɵɵpipe(17, "async");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(18, "div", 62)(19, "a", 63);
    i0.ɵɵlistener("click", function BaseNavbarComponent_div_0_ng_template_3_Template_a_click_19_listener() { i0.ɵɵrestoreView(_r74); const ctx_r73 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r73.openSearchBox()); });
    i0.ɵɵelement(20, "scrm-image", 64);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(21, "div", 65)(22, "scrm-search-bar", 66, 67);
    i0.ɵɵlistener("isSearchVisible", function BaseNavbarComponent_div_0_ng_template_3_Template_scrm_search_bar_isSearchVisible_22_listener($event) { i0.ɵɵrestoreView(_r74); const ctx_r75 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r75.closeSearchBox($event)); })("searchExpression", function BaseNavbarComponent_div_0_ng_template_3_Template_scrm_search_bar_searchExpression_22_listener($event) { i0.ɵɵrestoreView(_r74); const ctx_r76 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r76.search($event)); });
    i0.ɵɵelementEnd()()();
    i0.ɵɵtemplate(24, BaseNavbarComponent_div_0_ng_template_3_div_24_Template, 10, 3, "div", 68);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r5 = i0.ɵɵnextContext();
    let tmp_2_0;
    let tmp_3_0;
    i0.ɵɵadvance(6);
    i0.ɵɵclassProp("dropdown-menu-right", !ctx_r5.mobileNavbar)("dropdown-menu-right-center", ctx_r5.mobileNavbar);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ((tmp_2_0 = ctx_r5.navbar == null ? null : ctx_r5.navbar.current == null ? null : ctx_r5.navbar.current.module) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "") && ctx_r5.currentQuickActions.length);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ((tmp_3_0 = ctx_r5 == null ? null : ctx_r5.navigation == null ? null : ctx_r5.navigation.quickActions) !== null && tmp_3_0 !== undefined ? tmp_3_0 : i0.ɵɵpureFunction0(23, _c3)).length);
    i0.ɵɵadvance(6);
    i0.ɵɵclassProp("dropdown-menu-right", !ctx_r5.mobileNavbar);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("menuItems", i0.ɵɵpipeBind3(16, 17, i0.ɵɵpipeBind1(17, 21, ctx_r5.recentlyViewed$), 0, ctx_r5.recentlyViewedCount));
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngClass", ctx_r5.isSearchBoxVisible() ? "d-none" : "d-block");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngClass", ctx_r5.isSearchBoxVisible() ? "d-block" : "d-none")("@mobileSearchBarAnm", undefined);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", "LBL_SEARCH")("klass", "search-bar-global")("searchTrigger", "enter")("isMobile", ctx_r5.isSmallScreen());
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r5.notificationsEnabled && ctx_r5.checkAppStrings(vm_r1.appStrings) && ctx_r5.arePreferencesInitialized(vm_r1.userPreferences));
} }
function BaseNavbarComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, BaseNavbarComponent_div_0_ng_template_1_Template, 5, 0, "ng-template", 2);
    i0.ɵɵtemplate(2, BaseNavbarComponent_div_0_ng_container_2_Template, 4, 3, "ng-container", 3);
    i0.ɵɵtemplate(3, BaseNavbarComponent_div_0_ng_template_3_Template, 25, 24, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.loaded);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.loaded);
} }
class BaseNavbarComponent {
    static { this.instances = []; }
    constructor(navigationStore, languageStore, userPreferenceStore, systemConfigStore, appState, authService, moduleNavigation, screenSize, asyncActionService, notificationStore, globalRecentlyViewedStore, globalSearch, breakpointObserver, router) {
        this.navigationStore = navigationStore;
        this.languageStore = languageStore;
        this.userPreferenceStore = userPreferenceStore;
        this.systemConfigStore = systemConfigStore;
        this.appState = appState;
        this.authService = authService;
        this.moduleNavigation = moduleNavigation;
        this.screenSize = screenSize;
        this.asyncActionService = asyncActionService;
        this.notificationStore = notificationStore;
        this.globalRecentlyViewedStore = globalRecentlyViewedStore;
        this.globalSearch = globalSearch;
        this.breakpointObserver = breakpointObserver;
        this.router = router;
        this.loaded = true;
        this.mainNavCollapse = true;
        this.subNavCollapse = true;
        this.mobileSubNav = false;
        this.backLink = false;
        this.mainNavLink = true;
        this.submenu = [];
        this.moduleNameMapper = new ModuleNameMapper(this.systemConfigStore);
        this.actionNameMapper = new ActionNameMapper(this.systemConfigStore);
        this.routeConverter = new RouteConverter(this.moduleNameMapper, this.actionNameMapper, this.systemConfigStore);
        this.maxTabs = 8;
        this.screen = ScreenSize.Medium;
        this.notificationsEnabled = false;
        this.subs = [];
        this.mobileNavbar = false;
        this.isSmallScreen = signal(false);
        this.isTabletScreen = signal(false);
        this.recentlyViewedCount = 10;
        this.isSearchBoxVisible = signal(false);
        this.languages$ = this.languageStore.vm$;
        this.userPreferences$ = this.userPreferenceStore.userPreferences$;
        this.currentUser$ = this.authService.currentUser$;
        this.appState$ = this.appState.vm$;
        this.navigation$ = this.navigationStore.vm$;
        this.recentlyViewed$ = this.globalRecentlyViewedStore.globalRecentlyViewed$;
        this.vm$ = this.navigation$.pipe(combineLatestWith(this.userPreferences$, this.currentUser$, this.appState$, this.screenSize.screenSize$, this.languages$), map(([navigation, userPreferences, currentUser, appState, screenSize, language]) => {
            if (screenSize) {
                this.screen = screenSize;
                this.onResize();
            }
            if (navigation && navigation.modules) {
                this.navigation = navigation;
            }
            this.calculateMaxTabs(navigation);
            this.getModuleQuickActions(appState.module);
            this.navbar.resetMenu();
            if (ready([language.appStrings, language.modStrings, language.appListStrings, userPreferences, currentUser])) {
                this.navbar.build(navigation, currentUser, this.maxTabs);
            }
            return {
                navigation,
                userPreferences,
                appState,
                appStrings: language.appStrings || {},
                appListStrings: language.appListStrings || {}
            };
        }));
    }
    /**
     * Public API
     */
    onResize() {
        const innerWidth = window.innerWidth;
        this.mobileNavbar = innerWidth <= 768;
        this.isSmallScreen.set(innerWidth < 600);
        this.isTabletScreen.set(innerWidth <= 992);
        this.isSearchBoxVisible.set(innerWidth >= 600);
    }
    ngOnInit() {
        const navbar = new NavbarAbstract(this.routeConverter, this.moduleNavigation, this.userPreferenceStore, this.languageStore, this.appState, this.moduleNameMapper);
        this.setNavbar(navbar);
        this.authService.isUserLoggedIn.subscribe(value => {
            this.isUserLoggedIn = value;
        });
        window.dispatchEvent(new Event('resize'));
        this.notificationCount$ = this.notificationStore.notificationsUnreadTotal$;
        this.recentlyViewedCount = this.systemConfigStore.getUi('global_recently_viewed');
        this.subs.push(this.notificationStore.notificationsEnabled$.subscribe(notificationsEnabled => {
            this.notificationsEnabled = notificationsEnabled;
        }));
        this.subs.push(this.breakpointObserver.observe([
            Breakpoints.XSmall,
        ]).subscribe((result) => {
            let hasSearchTerm;
            if (!!this.searchTermRef?.searchForm.get('searchTerm').value) {
                hasSearchTerm = true;
            }
            else {
                hasSearchTerm = false;
            }
            if (result.matches && !hasSearchTerm) {
                this.isSearchBoxVisible.set(false);
            }
        }));
    }
    ngOnDestroy() {
        this.authService.isUserLoggedIn.unsubscribe();
        this.subs.forEach(sub => sub.unsubscribe());
    }
    checkAppStrings(appStrings) {
        return appStrings && Object.keys(appStrings).length > 0;
    }
    arePreferencesInitialized(preferences) {
        return preferences && Object.keys(preferences).length;
    }
    markAsRead() {
        this.notificationStore.markNotificationsAsRead();
    }
    ngAfterViewInit() {
        if (!this.mobileGlobalLinkTitle?.nativeElement?.offsetWidth) {
            return;
        }
        this.dropdownLength = this.mobileGlobalLinkTitle.nativeElement.offsetWidth;
    }
    /**
     * Change subnavigation
     *
     * @param {object} event triggered
     * @param {object} items
     */
    changeSubNav(event, items) {
        this.mobileSubNav = !this.mobileSubNav;
        this.backLink = !this.backLink;
        this.mainNavLink = !this.mainNavLink;
        this.submenu = items;
    }
    /**
     * Set link flags
     */
    navBackLink() {
        this.mobileSubNav = !this.mobileSubNav;
        this.backLink = !this.backLink;
        this.mainNavLink = !this.mainNavLink;
    }
    /**
     * Get home page
     *
     * @returns {string} homepage
     */
    getHomePage() {
        return this.systemConfigStore.getHomePage();
    }
    /**
     * Internal API
     */
    /**
     * Set navbar model
     *
     * @param {object} navbar model
     */
    setNavbar(navbar) {
        this.navbar = navbar;
        this.loaded = true;
    }
    /**
     * Check if is loaded
     *
     * @returns {{boolean}} is loaded
     */
    isLoaded() {
        return this.loaded;
    }
    calculateMaxTabs(navigation) {
        const sizeMap = this.systemConfigStore.getConfigValue('navigation_tab_limits');
        if (this.screen && sizeMap) {
            let maxTabs = sizeMap[this.screen];
            if (!maxTabs || navigation.maxTabs && navigation.maxTabs < maxTabs) {
                maxTabs = navigation.maxTabs;
            }
            this.maxTabs = maxTabs;
        }
    }
    getModuleQuickActions(module) {
        const moduleNavigation = this?.navigation?.modules[module] ?? null;
        const moduleNavigationMenu = moduleNavigation?.menu ?? [];
        if (moduleNavigation === null || !moduleNavigationMenu.length) {
            this.currentQuickActions = [];
        }
        const actions = [];
        moduleNavigationMenu.forEach(entry => {
            if (!entry.url || !entry.quickAction) {
                return;
            }
            const url = entry?.url ?? '';
            actions.push({
                ...entry,
                url: url.replace('/#/', '/')
            });
        });
        this.currentQuickActions = actions;
    }
    handleProcess(action) {
        if (!action.process) {
            return;
        }
        const processType = action.process;
        const options = {
            action: processType,
            module: action.module,
        };
        this.asyncActionService.run(processType, options).pipe(take(1)).subscribe();
    }
    openSearchBox() {
        if (this.isSmallScreen()) {
            this.isSearchBoxVisible.set(true);
        }
    }
    closeSearchBox(isVisible) {
        this.isSearchBoxVisible.set(isVisible);
    }
    search(searchTerm) {
        const searchController = this.systemConfigStore.getConfigValue('search')?.controller ?? '';
        this.globalSearch.navigateToSearch(searchTerm, searchController).finally();
    }
    toggleSidebar() {
        this.appState.toggleSidebar();
    }
    closeNotificationMenu() {
        this.subs.push(this.router.events.pipe(filter(event => event instanceof NavigationEnd), take(1)).subscribe(() => {
            this.alertDropdown.close();
        }));
    }
    static { this.ɵfac = function BaseNavbarComponent_Factory(t) { return new (t || BaseNavbarComponent)(i0.ɵɵdirectiveInject(NavigationStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(AsyncActionService), i0.ɵɵdirectiveInject(NotificationStore), i0.ɵɵdirectiveInject(GlobalRecentlyViewedStore), i0.ɵɵdirectiveInject(GlobalSearch), i0.ɵɵdirectiveInject(i1$1.BreakpointObserver), i0.ɵɵdirectiveInject(i1$2.Router)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseNavbarComponent, selectors: [["scrm-base-navbar"]], viewQuery: function BaseNavbarComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$e, 5);
            i0.ɵɵviewQuery(_c1$2, 5);
            i0.ɵɵviewQuery(_c2, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.mobileGlobalLinkTitle = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.searchTermRef = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.alertDropdown = _t.first);
        } }, hostBindings: function BaseNavbarComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("resize", function BaseNavbarComponent_resize_HostBindingHandler($event) { return ctx.onResize($event); }, false, i0.ɵɵresolveWindow);
        } }, decls: 2, vars: 3, consts: [["class", "top-panel fixed-top", 4, "ngIf"], [1, "top-panel", "fixed-top"], [3, "ngIf"], [4, "ngIf"], ["actionIcons", ""], [1, "navbar", "navbar-expand-lg"], [1, "navbar-collapse", "collapse", "order-4", "order-md-0", "collapsenav"], [1, "navbar-nav"], [1, "top-nav", "nav-item"], [1, "navbar", "ml-0", "pl-0"], [1, "navbar-collapse"], [1, "pl-0"], [1, "navbar", "mobile-nav-block", "mobilenavbar"], [1, "d-flex"], ["type", "button", 1, "navbar-toggler", 3, "click"], ["image", "hamburger", 1, "responsive-menu-toggler"], [1, "navbar-expand", 3, "ngClass"], [1, "navbar-nav", "h-100"], ["class", "top-nav nav-item dropdown mobile-navbar-active-module h-100 non-grouped", 4, "ngIf"], ["class", "top-nav nav-item dropdown mobile-navbar-active-module main-grouped", 4, "ngIf"], [1, "d-flex", "align-items-center"], [4, "ngTemplateOutlet"], ["ngbDropdown", "", 1, "global-links", "action-dropdown"], [1, "global-link-item"], ["ngbDropdownToggle", "", 1, "nav-link", "primary-global-link", "dropdown-toggle"], ["mobileGlobalLinkTitle", ""], ["image", "user", 1, "global-action-icon", "sicon-2x"], ["aria-labelledby", "navbarDropdownMenuLink", "ngbDropdownMenu", "", 1, "dropdown-menu", "global-links-dropdown", "border", "shadow-sm-2"], [1, "global-user-name"], [1, "top-nav", "nav-item", "dropdown", "mobile-navbar-active-module", "h-100", "non-grouped"], [3, "item"], [1, "top-nav", "nav-item", "dropdown", "mobile-navbar-active-module", "main-grouped"], [3, "item", "subNavCollapse"], [4, "ngFor", "ngForOf"], ["ngbDropdownItem", "", 1, "dropdown-item", "global-links-sublink", 3, "href", "target"], [1, "navbar", "navbar-expand-md", "navbar-1"], [1, "navbar-collapse", "collapse", "collapsenav", 3, "ngbCollapse"], [3, "active", "route"], ["ngbDropdownToggle", "", 1, "nav-link", "primary-global-link"], ["aria-labelledby", "navbarDropdownMenuLink", "ngbDropdownMenu", "", 1, "dropdown-menu", "global-links-dropdown", "border", "shadow-sm-2", "dropdown-menu-right"], [1, "navbar-nav", "grouped"], ["class", "top-nav nav-item dropdown non-grouped active", 4, "ngIf"], ["class", "top-nav nav-item dropdown main-grouped", 4, "ngFor", "ngForOf"], ["labelKey", "LBL_TABGROUP_ALL", 3, "items", "index"], [1, "top-nav", "nav-item", "dropdown", "main-grouped"], [3, "item", "subNavCollapse", "index"], [1, "top-nav", "nav-item", "dropdown", "non-grouped", "active"], [3, "item", "index"], ["class", "top-nav nav-item dropdown non-grouped", 4, "ngFor", "ngForOf"], ["labelKey", "LBL_MORE", 3, "items", "index"], [1, "top-nav", "nav-item", "dropdown", "non-grouped"], [1, "action-group", "navbar-action-group"], ["ngbDropdown", "", 1, "action-new", "action-dropdown"], [1, "navbar-nav", "border-0"], ["type", "button", "aria-label", "Quick Create", "ngbDropdownToggle", "", 1, "action-link", "primary-global-link"], ["image", "plus", 1, "action-btn-icon"], ["ngbDropdownMenu", "", 1, "dropdown-menu", "dropdown-menu-left", "border", "shadow-sm-2"], ["ngbDropdown", "", 1, "action-history", "action-dropdown"], ["type", "button", "aria-label", "Recently Viewed", "ngbDropdownToggle", "", 1, "action-link", "primary-global-link"], ["image", "recently_viewed", 1, "action-btn-icon"], ["ngbDropdownMenu", "", 1, "dropdown-menu", "border", "shadow-sm-2", "dropdown-menu-right", "scrollbar-thick", "recently-viewed-nav-header"], ["ngbDropdownItem", "", 1, "recently-viewed", 3, "menuItems"], [1, "d-flex", "align-items-center", "px-1", "action-search"], ["type", "button", "aria-label", "Search", 1, "search-mobile-view", "action-link", "primary-global-link", 3, "ngClass", "click"], ["image", "search", 1, "action-btn-icon"], [3, "ngClass"], [3, "labelKey", "klass", "searchTrigger", "isMobile", "isSearchVisible", "searchExpression"], ["searchTerm", ""], ["class", "action-alert action-dropdown", "ngbDropdown", "", 4, "ngIf"], [1, "new-list-item-header", "font-weight-bold"], ["labelKey", "LBL_MODULE_NAME", 3, "module"], ["class", "new-list-item", "ngbDropdownItem", "", 4, "ngFor", "ngForOf"], ["ngbDropdownItem", "", 1, "new-list-item"], [1, "d-flex", "align-items-center", 3, "routerLink", "queryParams"], [1, "new-list-item-label", 3, "labelKey", "module"], [1, "d-flex", "align-items-center", 3, "click"], ["labelKey", "LBL_QUICK_ACTIONS"], ["ngbDropdown", "", 1, "action-alert", "action-dropdown"], ["alertDropdown", "ngbDropdown"], ["type", "button", "ngbDropdownToggle", "", 1, "action-link", "primary-global-link", 3, "mouseenter"], ["image", "alert", 1, "action-btn-icon"], ["aria-labelledby", "navbarDropdownMenuLink", "ngbDropdownMenu", "", 1, "dropdown-menu", "border", "shadow-sm-2", "dropdown-menu-right", 3, "click"], ["class", "badge badge-position rounded-pill bg-danger text-white", 4, "ngIf"], [1, "badge", "badge-position", "rounded-pill", "bg-danger", "text-white"]], template: function BaseNavbarComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseNavbarComponent_div_0_Template, 5, 2, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i2.NgTemplateOutlet, LogoUiComponent, LogoutUiComponent, i3$1.NgbCollapse, i3$1.NgbDropdown, i3$1.NgbDropdownToggle, i3$1.NgbDropdownMenu, i3$1.NgbDropdownItem, i1$2.RouterLink, ImageComponent, LabelComponent, NotificationsComponent, SearchBarComponent, RecentlyViewedComponent, MenuItemComponent, HomeMenuItemComponent, GroupedMenuItemComponent, MenuItemsListComponent, i2.AsyncPipe, i2.SlicePipe], encapsulation: 2, data: { animation: [
                trigger('mobileSearchBarAnm', [
                    transition(':enter', useAnimation(backInDown, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                ])
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseNavbarComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-navbar', animations: [
                    trigger('mobileSearchBarAnm', [
                        transition(':enter', useAnimation(backInDown, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                    ])
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start of main navbar section -->\n\n<div *ngIf=\"(vm$ | async) as vm\" class=\"top-panel fixed-top\">\n\n    <!-- Start of empty navbar section until data is loaded -->\n\n    <ng-template [ngIf]=\"!loaded\">\n        <nav class=\"navbar navbar-expand-lg\">\n            <div class=\"navbar-collapse collapse order-4 order-md-0 collapsenav\">\n                <ul class=\"navbar-nav\">\n                    <li class=\"top-nav nav-item\">&nbsp;\n                    </li>\n                </ul>\n            </div>\n        </nav>\n    </ng-template>\n\n    <!-- End of empty  section until data is loaded -->\n\n    <!-- Start of empty navbar with logo -->\n\n    <ng-container *ngIf=\"loaded\">\n        <ng-container *ngIf=\"!this.isUserLoggedIn\">\n            <nav class=\"navbar ml-0 pl-0\">\n                <div class=\"navbar-collapse\">\n                    <ul class=\"navbar-nav\">\n                        <li class=\"pl-0\">\n                            <scrm-logo-ui></scrm-logo-ui>\n                        </li>\n                    </ul>\n                </div>\n            </nav>\n        </ng-container>\n\n        <!-- End of empty navbar section with logo -->\n\n        <!-- Start of mobile navigation section -->\n\n        <ng-container *ngIf=\"this.isUserLoggedIn && mobileNavbar\">\n            <ul class=\"navbar mobile-nav-block mobilenavbar\">\n                <div class=\"d-flex\">\n                    <button (click)=\"toggleSidebar()\" class=\"navbar-toggler\" type=\"button\">\n                        <scrm-image class=\"responsive-menu-toggler\" image=\"hamburger\"></scrm-image>\n                    </button>\n                    <nav class=\"navbar-expand\" [ngClass]=\"(isSmallScreen() && isSearchBoxVisible()) ? 'd-none' : 'd-block'\">\n                        <ul class=\"navbar-nav h-100\">\n                            <li *ngIf=\"navbar.current && !navbar.current.isGroupedMenu\" class=\"top-nav nav-item dropdown mobile-navbar-active-module h-100 non-grouped\">\n                                <scrm-menu-item [item]=\"navbar.current\"></scrm-menu-item>\n                            </li>\n                            <li *ngIf=\"navbar.current?.submenu  && navbar.current.isGroupedMenu\" class=\"top-nav nav-item dropdown mobile-navbar-active-module main-grouped\">\n                                <scrm-grouped-menu-item\n                                    [item]=\"navbar.current\"\n                                    [subNavCollapse]=\"subNavCollapse\">\n                                </scrm-grouped-menu-item>\n                            </li>\n                        </ul>\n                    </nav>\n                </div>\n\n                <div class=\"d-flex align-items-center\">\n                    <ng-container *ngTemplateOutlet=\"actionIcons\"></ng-container>\n                    <div class=\"global-links action-dropdown\" ngbDropdown>\n                        <li class=\"global-link-item\">\n                            <a #mobileGlobalLinkTitle class=\"nav-link primary-global-link dropdown-toggle\"\n                               ngbDropdownToggle>\n                                <scrm-image class=\"global-action-icon sicon-2x\" image=\"user\"></scrm-image>\n                            </a>\n                            <div [style.min-width.px]=\"mobileGlobalLinkTitle.offsetWidth\"\n                                 aria-labelledby=\"navbarDropdownMenuLink\"\n                                 class=\"dropdown-menu global-links-dropdown border shadow-sm-2\" ngbDropdownMenu>\n                                <span\n                                    class=\"global-user-name\">{{ navbar.currentUser.firstName }} {{ navbar.currentUser.lastName }}</span>\n                                <ng-template [ngIf]=\"navbar.globalActions\">\n                                    <ng-container\n                                        *ngFor=\"let globalAction of navbar.globalActions; let first = first; let last = last;\">\n                                        <a class=\"dropdown-item global-links-sublink\"\n                                           href=\"{{ globalAction.link.url }}\"\n                                           ngbDropdownItem\n                                           target=\"{{ globalAction.link.target }}\">{{ globalAction.link.label }}\n                                        </a>\n                                        <hr *ngIf=\"last === true || first === true\"/>\n                                    </ng-container>\n                                </ng-template>\n                                <scrm-logout-ui></scrm-logout-ui>\n                            </div>\n                        </li>\n                    </div>\n                </div>\n\n            </ul>\n\n        </ng-container>\n\n        <!-- End of mobile navigation section-->\n\n        <!-- Start of navbar section with data once authenticated -->\n\n        <ng-container *ngIf=\"this.isUserLoggedIn && !mobileNavbar\">\n            <nav class=\"navbar navbar-expand-md navbar-1\">\n                <div [ngbCollapse]=\"mainNavCollapse\" class=\"navbar-collapse collapse collapsenav\">\n                        <scrm-home-menu-item\n                            [active]=\"vm.appState.module && vm.appState.module === 'home'\"\n                            [route]=\"getHomePage()\"\n                        ></scrm-home-menu-item>\n\n                        <!-- Navbar with grouped tabs -->\n\n                        <ng-container *ngIf=\"vm.userPreferences['navigation_paradigm'] == 'gm'\">\n\n                            <ul class=\"navbar-nav grouped\">\n\n                                <ng-container *ngIf=\"navbar.current && navbar.current.isGroupedMenu\">\n                                    <li class=\"top-nav nav-item dropdown main-grouped\">\n                                        <scrm-grouped-menu-item\n                                                [item]=\"navbar.current\"\n                                                [subNavCollapse]=\"subNavCollapse\"\n                                                [index]=\"1\"\n                                        >\n                                        </scrm-grouped-menu-item>\n\n                                    </li>\n                                </ng-container>\n\n                                <li *ngIf=\"navbar.current && !navbar.current.isGroupedMenu\" class=\"top-nav nav-item dropdown non-grouped active\">\n                                    <scrm-menu-item [item]=\"navbar.current\" [index]=\"1\"></scrm-menu-item>\n                                </li>\n\n                                <li *ngFor=\"let item of navbar.menu; let i = index;\" class=\"top-nav nav-item dropdown main-grouped\">\n                                    <scrm-grouped-menu-item\n                                        [item]=\"item\"\n                                        [subNavCollapse]=\"subNavCollapse\"\n                                        [index]=\"i+2\"\n                                    >\n                                    </scrm-grouped-menu-item>\n\n                                </li>\n                            </ul>\n\n                            <scrm-menu-items-list [items]=\"navbar.all.modules\"\n                                                  labelKey=\"LBL_TABGROUP_ALL\"\n                                                  [index]=\"navbar.menu.length + 2\">\n                            </scrm-menu-items-list>\n\n                        </ng-container>\n\n\n                        <!-- END Navbar with grouped tabs -->\n\n                        <!-- Navbar with non-grouped tabs -->\n\n                        <ng-container *ngIf=\"vm.userPreferences['navigation_paradigm'] != 'gm'\">\n\n                            <ul class=\"navbar-nav\">\n                                <li *ngIf=\"navbar.current && !navbar.current.isGroupedMenu\" class=\"top-nav nav-item dropdown non-grouped active\">\n                                    <scrm-menu-item [item]=\"navbar.current\" [index]=\"1\"></scrm-menu-item>\n                                </li>\n\n                                <ng-container *ngIf=\"navbar.current?.submenu  && navbar.current.isGroupedMenu\">\n                                    <li class=\"top-nav nav-item dropdown main-grouped\">\n                                        <scrm-grouped-menu-item\n                                            [item]=\"navbar.current\"\n                                            [subNavCollapse]=\"subNavCollapse\"\n                                            [index]=\"1\">\n                                        </scrm-grouped-menu-item>\n                                    </li>\n                                </ng-container>\n\n                                <li *ngFor=\"let item of navbar.menu; let i = index\" class=\"top-nav nav-item dropdown non-grouped\">\n                                    <scrm-menu-item [item]=\"item\" [index]=\"i+2\"></scrm-menu-item>\n                                </li>\n                            </ul>\n\n                        <scrm-menu-items-list [items]=\"navbar.all.modules\"\n                                              labelKey=\"LBL_MORE\"\n                                                [index]=\"navbar.menu.length + 2\">\n                        </scrm-menu-items-list>\n\n                        </ng-container>\n\n                        <!-- END Navbar with non-grouped tabs -->\n\n                </div>\n\n                <ng-container *ngTemplateOutlet=\"actionIcons\"></ng-container>\n\n                <!-- Global Links -->\n\n                <div class=\"global-links action-dropdown\" ngbDropdown>\n                    <ul class=\"navbar-nav\">\n                        <li class=\"global-link-item\">\n                            <a class=\"nav-link primary-global-link\" ngbDropdownToggle>\n                                <scrm-image class=\"global-action-icon sicon-2x\" image=\"user\"></scrm-image>\n                            </a>\n                            <div aria-labelledby=\"navbarDropdownMenuLink\"\n                                 class=\"dropdown-menu global-links-dropdown border shadow-sm-2 dropdown-menu-right\" ngbDropdownMenu>\n                                <span\n                                    class=\"global-user-name\">{{ navbar.currentUser.firstName }} {{ navbar.currentUser.lastName }}</span>\n                                <ng-container *ngIf=\"navbar.globalActions\">\n                                    <ng-container\n                                        *ngFor=\"let globalAction of navbar.globalActions; let first = first; let last = last;\">\n                                        <a class=\"dropdown-item global-links-sublink\"\n                                           href=\"{{ globalAction.link.url }}\"\n                                           ngbDropdownItem\n                                           target=\"{{ globalAction.link.target }}\">{{ globalAction.link.label }}\n                                        </a>\n                                        <hr *ngIf=\"last === true || first === true\"/>\n                                    </ng-container>\n\n                                </ng-container>\n                                <scrm-logout-ui></scrm-logout-ui>\n                            </div>\n                        </li>\n                    </ul>\n                </div>\n\n                <!-- END Global Links -->\n\n            </nav>\n\n            <!-- End of navbar section with data once authenticated -->\n\n        </ng-container>\n    </ng-container>\n\n    <ng-template #actionIcons>\n        <div class=\"action-group navbar-action-group\">\n            <!--Quick Create-->\n            <div class=\"action-new action-dropdown\" ngbDropdown>\n                <ul class=\"navbar-nav border-0\">\n                    <li class=\"global-link-item\">\n                        <a class=\"action-link primary-global-link\" type=\"button\" aria-label=\"Quick Create\" ngbDropdownToggle>\n                            <scrm-image class=\"action-btn-icon\" image=\"plus\"></scrm-image>\n                        </a>\n                        <ul [class.dropdown-menu-right]=\"!mobileNavbar\"\n                            [class.dropdown-menu-right-center]=\"mobileNavbar\"\n                            class=\"dropdown-menu dropdown-menu-left border shadow-sm-2\" ngbDropdownMenu>\n\n                            <ng-container *ngIf=\"(navbar?.current?.module ?? '') && currentQuickActions.length\">\n                                <li class=\"new-list-item-header font-weight-bold\">\n                                    <scrm-label labelKey=\"LBL_MODULE_NAME\" [module]=\"navbar.current.module\"></scrm-label>\n                                </li>\n                                <li class=\"new-list-item\" *ngFor=\"let moduleQuickAction of currentQuickActions\" ngbDropdownItem>\n                                    <ng-container *ngIf=\"!moduleQuickAction.process\">\n                                        <a [routerLink]=\"moduleQuickAction.url\" [queryParams]=\"moduleQuickAction?.params ?? null\" class=\"d-flex align-items-center\">\n                                            <scrm-label [labelKey]=\"moduleQuickAction.labelKey\" [module]=\"navbar.current.module\" class=\"new-list-item-label\"></scrm-label>\n                                        </a>\n                                    </ng-container>\n                                    <ng-container *ngIf=\"moduleQuickAction.process\">\n                                        <a (click)=\"handleProcess(moduleQuickAction)\" class=\"d-flex align-items-center\">\n                                            <scrm-label [labelKey]=\"moduleQuickAction.labelKey\" [module]=\"navbar.current.module\" class=\"new-list-item-label\"></scrm-label>\n                                        </a>\n                                    </ng-container>\n\n                                </li>\n                            </ng-container>\n\n                            <ng-container *ngIf=\"(this?.navigation?.quickActions ?? []).length\">\n                                <li class=\"new-list-item-header font-weight-bold\">\n                                    <scrm-label labelKey=\"LBL_QUICK_ACTIONS\"></scrm-label>\n                                </li>\n                                <li class=\"new-list-item\" *ngFor=\"let quickAction of (this?.navigation?.quickActions ?? [])\" ngbDropdownItem>\n                                    <ng-container *ngIf=\"!quickAction.process\">\n                                        <a [routerLink]=\"quickAction.url\" [queryParams]=\"quickAction?.params ?? null\" class=\"d-flex align-items-center\">\n                                            <scrm-label [labelKey]=\"quickAction.labelKey\" [module]=\"quickAction.module\" class=\"new-list-item-label\"></scrm-label>\n                                        </a>\n                                    </ng-container>\n                                    <ng-container *ngIf=\"quickAction.process\">\n                                        <a (click)=\"handleProcess(quickAction)\" class=\"d-flex align-items-center\">\n                                            <scrm-label [labelKey]=\"quickAction.labelKey\" [module]=\"quickAction.module\" class=\"new-list-item-label\"></scrm-label>\n                                        </a>\n                                    </ng-container>\n                                </li>\n                            </ng-container>\n                        </ul>\n                    </li>\n                </ul>\n            </div>\n            <!--Recently Viewed-->\n            <div class=\"action-history action-dropdown\" ngbDropdown>\n                <ul class=\"navbar-nav border-0\">\n                    <li class=\"global-link-item\">\n                        <a class=\"action-link primary-global-link\" type=\"button\" aria-label=\"Recently Viewed\" ngbDropdownToggle>\n                            <scrm-image class=\"action-btn-icon\" image=\"recently_viewed\"></scrm-image>\n                        </a>\n                        <div class=\"dropdown-menu border shadow-sm-2 dropdown-menu-right scrollbar-thick recently-viewed-nav-header\"\n                             [class.dropdown-menu-right]=\"!mobileNavbar\" ngbDropdownMenu>\n                                 <scrm-recently-viewed [menuItems]=\"recentlyViewed$ | async | slice:0:recentlyViewedCount\"\n                                                       ngbDropdownItem class=\"recently-viewed\"></scrm-recently-viewed>\n                        </div>\n                    </li>\n                </ul>\n            </div>\n\n            <!--Searchbar-->\n            <div class=\"d-flex align-items-center px-1 action-search\">\n                <a class=\"search-mobile-view action-link primary-global-link\" [ngClass]=\"isSearchBoxVisible() ? 'd-none' : 'd-block'\"\n                   type=\"button\" (click)=\"openSearchBox()\" aria-label=\"Search\">\n                    <scrm-image class=\"action-btn-icon\" image=\"search\"></scrm-image>\n                </a>\n\n                <div [ngClass]=\"isSearchBoxVisible() ? 'd-block' : 'd-none'\" [@mobileSearchBarAnm]>\n                    <scrm-search-bar\n                        [labelKey]=\"'LBL_SEARCH'\"\n                        [klass]=\"'search-bar-global'\"\n                        [searchTrigger]=\"'enter'\"\n                        [isMobile]=\"isSmallScreen()\"\n                        (isSearchVisible)=\"closeSearchBox($event)\"\n                        (searchExpression)=\"search($event)\" #searchTerm>\n                    </scrm-search-bar>\n                </div>\n            </div>\n            <!--Notifications-->\n            <div *ngIf=\"notificationsEnabled && checkAppStrings(vm.appStrings) && arePreferencesInitialized(vm.userPreferences)\"\n                 class=\"action-alert action-dropdown\" ngbDropdown #alertDropdown=\"ngbDropdown\">\n                <ul class=\"navbar-nav border-0\">\n                    <li class=\"global-link-item\">\n                        <a class=\"action-link primary-global-link\" type=\"button\"\n                           (mouseenter)=\"markAsRead()\" ngbDropdownToggle>\n                            <scrm-image class=\"action-btn-icon\" image=\"alert\"></scrm-image>\n                        </a>\n                        <ng-container *ngIf=\"(notificationCount$ | async) as notificationCount\">\n                                    <span *ngIf=\"(notificationCount ?? false)\"\n                                          class=\"badge badge-position rounded-pill bg-danger text-white\">\n                                        <ng-container *ngIf=\"notificationCount > 0\">{{notificationCount }}</ng-container>\n                                    </span>\n                        </ng-container>\n                        <div class=\"dropdown-menu border shadow-sm-2 dropdown-menu-right\" aria-labelledby=\"navbarDropdownMenuLink\"\n                             (click)=\"closeNotificationMenu()\" ngbDropdownMenu>\n                            <scrm-notifications></scrm-notifications>\n                        </div>\n                    </li>\n                </ul>\n            </div>\n\n        </div>\n    </ng-template>\n\n</div>\n\n<!-- End of main navbar section -->\n" }]
    }], function () { return [{ type: NavigationStore }, { type: LanguageStore }, { type: UserPreferenceStore }, { type: SystemConfigStore }, { type: AppStateStore }, { type: AuthService }, { type: ModuleNavigation }, { type: ScreenSizeObserverService }, { type: AsyncActionService }, { type: NotificationStore }, { type: GlobalRecentlyViewedStore }, { type: GlobalSearch }, { type: i1$1.BreakpointObserver }, { type: i1$2.Router }]; }, { mobileGlobalLinkTitle: [{
            type: ViewChild,
            args: ['mobileGlobalLinkTitle']
        }], searchTermRef: [{
            type: ViewChild,
            args: ['searchTerm', { static: false }]
        }], alertDropdown: [{
            type: ViewChild,
            args: ['alertDropdown']
        }], onResize: [{
            type: HostListener,
            args: ['window:resize', ['$event']]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NavbarRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseNavbarComponent);
    }
    static { this.ɵfac = function NavbarRegistry_Factory(t) { return new (t || NavbarRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: NavbarRegistry, factory: NavbarRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NavbarRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NavbarUiComponent {
    constructor(registry) {
        this.registry = registry;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function NavbarUiComponent_Factory(t) { return new (t || NavbarUiComponent)(i0.ɵɵdirectiveInject(NavbarRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NavbarUiComponent, selectors: [["scrm-navbar-ui"]], decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent"]], template: function NavbarUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ndcDynamicComponent", ctx.getType);
        } }, dependencies: [i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NavbarUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-navbar-ui', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<ndc-dynamic [ndcDynamicComponent]=\"getType\"></ndc-dynamic>\n" }]
    }], function () { return [{ type: NavbarRegistry }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function BaseMenuRecentlyViewedComponent_ng_container_0_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵlistener("click", function BaseMenuRecentlyViewedComponent_ng_container_0_ng_container_3_div_1_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r4 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r4.onClick && ctx_r4.onClick()); });
    i0.ɵɵelementStart(1, "a", 5);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const recentRecord_r3 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", ctx_r2.buildRoute(recentRecord_r3));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", recentRecord_r3.attributes.item_summary, " ");
} }
function BaseMenuRecentlyViewedComponent_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseMenuRecentlyViewedComponent_ng_container_0_ng_container_3_div_1_Template, 3, 2, "div", 3);
    i0.ɵɵpipe(2, "slice");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind3(2, 1, ctx_r1.records, 0, ctx_r1.maxDisplayed));
} }
function BaseMenuRecentlyViewedComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "h4", 1);
    i0.ɵɵlistener("click", function BaseMenuRecentlyViewedComponent_ng_container_0_Template_h4_click_1_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.toggleCollapse()); });
    i0.ɵɵelement(2, "scrm-label", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseMenuRecentlyViewedComponent_ng_container_0_ng_container_3_Template, 3, 5, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", !ctx_r0.collapsed);
} }
class BaseMenuRecentlyViewedComponent {
    constructor(navigation, nameMapper, configs, metadata) {
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.configs = configs;
        this.metadata = metadata;
        this.collapsible = false;
        this.maxDisplayed = 5;
        this.collapsed = false;
        this.subs = [];
    }
    ngOnInit() {
        const ui = this.configs.getConfigValue('ui') ?? {};
        this.maxDisplayed = parseInt(ui.navigation_max_module_recently_viewed) ?? 5;
        this.initMetadata$();
        this.collapsed = !!this.collapsible;
    }
    ngOnDestroy() {
        this.clear();
    }
    ngOnChanges(changes) {
        const moduleChanges = changes?.module ?? null;
        if (moduleChanges === null) {
            return;
        }
        const previousModule = changes?.module?.previousValue ?? '';
        const currentModule = changes?.module?.currentValue ?? '';
        if (previousModule !== currentModule) {
            this.clear();
            this.initMetadata$();
        }
    }
    /**
     * Build route from recently viewed item
     * @param item
     */
    buildRoute(item) {
        const legacyName = item.attributes.module_name ?? '';
        const module = this.nameMapper.toFrontend(legacyName) ?? '';
        const id = item.attributes.item_id ?? '';
        return this.navigation.getRecordRouterLink(module, id);
    }
    /**
     * toggle collapse
     */
    toggleCollapse() {
        if (!this.collapsible) {
            return;
        }
        this.collapsed = !this.collapsed;
    }
    /**
     * Init metadata subscription
     * @protected
     */
    initMetadata$() {
        const moduleMeta$ = this.metadata.allModuleMetadata$.pipe(map(value => value[this.module] ?? null));
        this.subs.push(moduleMeta$.subscribe(meta => {
            this.records = meta?.recentlyViewed ?? null;
        }));
    }
    /**
     * Clear subscription and data
     * @protected
     */
    clear() {
        this.records = null;
        this.subs.forEach(sub => sub.unsubscribe());
    }
    static { this.ɵfac = function BaseMenuRecentlyViewedComponent_Factory(t) { return new (t || BaseMenuRecentlyViewedComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMenuRecentlyViewedComponent, selectors: [["scrm-base-menu-recently-viewed"]], inputs: { module: "module", onClick: "onClick", collapsible: "collapsible" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "recently-viewed-header", "mt-0", "pb-1", "pl-2", "pr-2", 3, "click"], ["labelKey", "LBL_LAST_VIEWED"], ["class", "nav-item", 3, "click", 4, "ngFor", "ngForOf"], [1, "nav-item", 3, "click"], [1, "nav-link", "action-link", "pb-2", "pt-2", 3, "routerLink"]], template: function BaseMenuRecentlyViewedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseMenuRecentlyViewedComponent_ng_container_0_Template, 4, 1, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.records && ctx.records.length);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i1$2.RouterLink, LabelComponent, i2.SlicePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMenuRecentlyViewedComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-menu-recently-viewed', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"records && records.length\">\n    <h4 (click)=\"toggleCollapse()\"\n        class=\"recently-viewed-header mt-0 pb-1 pl-2 pr-2\">\n        <scrm-label labelKey=\"LBL_LAST_VIEWED\"></scrm-label>\n    </h4>\n    <ng-container *ngIf=\"!collapsed\">\n        <div (click)=\"onClick && onClick()\"\n             *ngFor=\"let recentRecord of records | slice:0:maxDisplayed\"\n             class=\"nav-item\"\n        >\n            <a [routerLink]=\"this.buildRoute(recentRecord)\"\n               class=\"nav-link action-link pb-2 pt-2\">\n                {{ recentRecord.attributes.item_summary }}\n            </a>\n        </div>\n    </ng-container>\n</ng-container>\n" }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: SystemConfigStore }, { type: MetadataStore }]; }, { module: [{
            type: Input
        }], onClick: [{
            type: Input
        }], collapsible: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MenuRecentlyViewedRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseMenuRecentlyViewedComponent);
    }
    static { this.ɵfac = function MenuRecentlyViewedRegistry_Factory(t) { return new (t || MenuRecentlyViewedRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MenuRecentlyViewedRegistry, factory: MenuRecentlyViewedRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuRecentlyViewedRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$d = function (a0, a1, a2) { return { "module": a0, "onClick": a1, "collapsible": a2 }; };
function MenuRecentlyViewedComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction3(2, _c0$d, ctx_r0.module, ctx_r0.onClick, ctx_r0.collapsible));
} }
class MenuRecentlyViewedComponent {
    constructor(registry) {
        this.registry = registry;
        this.collapsible = false;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function MenuRecentlyViewedComponent_Factory(t) { return new (t || MenuRecentlyViewedComponent)(i0.ɵɵdirectiveInject(MenuRecentlyViewedRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MenuRecentlyViewedComponent, selectors: [["scrm-menu-recently-viewed"]], inputs: { module: "module", onClick: "onClick", collapsible: "collapsible" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function MenuRecentlyViewedComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MenuRecentlyViewedComponent_ndc_dynamic_0_Template, 1, 6, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuRecentlyViewedComponent, [{
        type: Component,
        args: [{ selector: 'scrm-menu-recently-viewed', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'module': module, 'onClick': onClick, 'collapsible': collapsible}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: MenuRecentlyViewedRegistry }]; }, { module: [{
            type: Input
        }], onClick: [{
            type: Input
        }], collapsible: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function BaseMenuFavoritesComponent_ng_container_0_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵlistener("click", function BaseMenuFavoritesComponent_ng_container_0_ng_container_3_div_1_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r4 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r4.onClick && ctx_r4.onClick()); });
    i0.ɵɵelementStart(1, "a", 5);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const favorite_r3 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("routerLink", ctx_r2.buildRoute(favorite_r3));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", favorite_r3.attributes.parent_name, " ");
} }
function BaseMenuFavoritesComponent_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, BaseMenuFavoritesComponent_ng_container_0_ng_container_3_div_1_Template, 3, 2, "div", 3);
    i0.ɵɵpipe(2, "slice");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind3(2, 1, ctx_r1.records, 0, ctx_r1.maxDisplayed));
} }
function BaseMenuFavoritesComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "h4", 1);
    i0.ɵɵlistener("click", function BaseMenuFavoritesComponent_ng_container_0_Template_h4_click_1_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.toggleCollapse()); });
    i0.ɵɵelement(2, "scrm-label", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, BaseMenuFavoritesComponent_ng_container_0_ng_container_3_Template, 3, 5, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", !ctx_r0.collapsed);
} }
class BaseMenuFavoritesComponent extends BaseFavoritesComponent {
    constructor(navigation, nameMapper, configs, metadata) {
        super(navigation, nameMapper, configs, metadata);
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.configs = configs;
        this.metadata = metadata;
        this.collapsible = false;
        this.collapsed = false;
    }
    ngOnInit() {
        super.ngOnInit();
        this.collapsed = !!this.collapsible;
    }
    /**
     * toggle collapse
     */
    toggleCollapse() {
        if (!this.collapsible) {
            return;
        }
        this.collapsed = !this.collapsed;
    }
    static { this.ɵfac = function BaseMenuFavoritesComponent_Factory(t) { return new (t || BaseMenuFavoritesComponent)(i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(MetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseMenuFavoritesComponent, selectors: [["scrm-base-menu-favorites"]], inputs: { onClick: "onClick", collapsible: "collapsible" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "favorite-header", "mt-0", "pb-1", "pl-2", "pr-2", 3, "click"], ["labelKey", "LBL_FAVORITES"], ["class", "nav-item", 3, "click", 4, "ngFor", "ngForOf"], [1, "nav-item", 3, "click"], [1, "nav-link", "action-link", "pb-2", "pt-2", 3, "routerLink"]], template: function BaseMenuFavoritesComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, BaseMenuFavoritesComponent_ng_container_0_Template, 4, 1, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.records && ctx.records.length);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i1$2.RouterLink, LabelComponent, i2.SlicePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMenuFavoritesComponent, [{
        type: Component,
        args: [{ selector: 'scrm-base-menu-favorites', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"records && records.length\">\n    <h4 (click)=\"toggleCollapse()\"\n        class=\"favorite-header mt-0 pb-1 pl-2 pr-2\">\n        <scrm-label labelKey=\"LBL_FAVORITES\"></scrm-label>\n    </h4>\n    <ng-container *ngIf=\"!collapsed\">\n        <div (click)=\"onClick && onClick()\"\n             *ngFor=\"let favorite of records | slice:0:maxDisplayed\"\n             class=\"nav-item\"\n        >\n            <a [routerLink]=\"this.buildRoute(favorite)\"\n               class=\"nav-link action-link pb-2 pt-2\">\n                {{ favorite.attributes.parent_name }}\n            </a>\n        </div>\n    </ng-container>\n\n</ng-container>\n" }]
    }], function () { return [{ type: ModuleNavigation }, { type: ModuleNameMapper }, { type: SystemConfigStore }, { type: MetadataStore }]; }, { onClick: [{
            type: Input
        }], collapsible: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class MenuFavoritesRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        this.register('default', 'default', BaseMenuFavoritesComponent);
    }
    static { this.ɵfac = function MenuFavoritesRegistry_Factory(t) { return new (t || MenuFavoritesRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MenuFavoritesRegistry, factory: MenuFavoritesRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuFavoritesRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$c = function (a0, a1, a2) { return { "module": a0, "onClick": a1, "collapsible": a2 }; };
function MenuFavoritesComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.getType)("ndcDynamicInputs", i0.ɵɵpureFunction3(2, _c0$c, ctx_r0.module, ctx_r0.onClick, ctx_r0.collapsible));
} }
class MenuFavoritesComponent {
    constructor(registry) {
        this.registry = registry;
        this.collapsible = false;
    }
    get getType() {
        return this.registry.get('default', 'default');
    }
    static { this.ɵfac = function MenuFavoritesComponent_Factory(t) { return new (t || MenuFavoritesComponent)(i0.ɵɵdirectiveInject(MenuFavoritesRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MenuFavoritesComponent, selectors: [["scrm-menu-favorites"]], inputs: { module: "module", onClick: "onClick", collapsible: "collapsible" }, decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function MenuFavoritesComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, MenuFavoritesComponent_ndc_dynamic_0_Template, 1, 6, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.getType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MenuFavoritesComponent, [{
        type: Component,
        args: [{ selector: 'scrm-menu-favorites', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"getType\"\n             [ndcDynamicComponent]=\"getType\"\n             [ndcDynamicInputs]=\"{'module': module, 'onClick': onClick, 'collapsible': collapsible}\">\n</ndc-dynamic>\n" }]
    }], function () { return [{ type: MenuFavoritesRegistry }]; }, { module: [{
            type: Input
        }], onClick: [{
            type: Input
        }], collapsible: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordGridComponent_ng_container_0_div_1_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 4);
    i0.ɵɵelement(1, "scrm-action-group-menu", 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("buttonClass", ctx_r3.config.buttonClass)("config", ctx_r3.config.actions);
} }
function RecordGridComponent_ng_container_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "scrm-field-grid", 2);
    i0.ɵɵtemplate(2, RecordGridComponent_ng_container_0_div_1_span_2_Template, 2, 2, "span", 3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵclassMapInterpolate1("record-grid ", ctx_r1.config && ctx_r1.config.klass || "", "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("actions", !!ctx_r1.config.actions)("appendActions", ctx_r1.config && ctx_r1.config.appendActions || false)("colClass", ctx_r1.config && ctx_r1.config.colClass)("fieldMode", ctx_r1.mode)("fields", ctx_r1.fields)("record", ctx_r1.record)("inputClass", ctx_r1.config && ctx_r1.config.inputClass)("labelClass", ctx_r1.config && ctx_r1.config.labelClass)("labelDisplay", ctx_r1.config && ctx_r1.config.labelDisplay || "top")("maxColumns", ctx_r1.maxColumns)("record", ctx_r1.record)("rowClass", ctx_r1.config && ctx_r1.config.rowClass)("sizeMap", ctx_r1.sizeMap)("colAlignItems", ctx_r1.config.colAlignItems);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.config.actions);
} }
function RecordGridComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordGridComponent_ng_container_0_div_1_Template, 3, 18, "div", 1);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 1, ctx_r0.vm$));
} }
class RecordGridComponent {
    constructor() {
        this.mode = 'detail';
        this.maxColumns = 4;
        this.sizeMap = {
            handset: 1,
            tablet: 2,
            web: 3,
            wide: 4
        };
        this.fields = [];
        this.special = [];
    }
    ngOnInit() {
        if (!this.config) {
            return;
        }
        const config = this.config;
        this.vm$ = config.record$.pipe(combineLatestWith(config.mode$, config.fields$, config.maxColumns$, config.sizeMap$), map(([record, mode, fields, maxColumns, sizeMap]) => {
            this.mode = mode;
            this.maxColumns = maxColumns;
            this.sizeMap = sizeMap;
            this.fields = this.getFields(record, fields);
            this.record = record;
            return { record, mode, fields, maxColumns };
        }));
    }
    getFields(record, fieldKeys) {
        if (!record || !fieldKeys || !record.fields) {
            return [];
        }
        const fields = [];
        fieldKeys.forEach(fieldKey => {
            if (!record.fields[fieldKey]) {
                return;
            }
            fields.push(record.fields[fieldKey]);
        });
        return fields;
    }
    static { this.ɵfac = function RecordGridComponent_Factory(t) { return new (t || RecordGridComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordGridComponent, selectors: [["scrm-record-grid"]], inputs: { config: "config" }, decls: 1, vars: 1, consts: [[4, "ngIf"], [3, "class", 4, "ngIf"], [3, "actions", "appendActions", "colClass", "fieldMode", "fields", "record", "inputClass", "labelClass", "labelDisplay", "maxColumns", "rowClass", "sizeMap", "colAlignItems"], ["class", "float-right", "field-grid-actions", "", 4, "ngIf"], ["field-grid-actions", "", 1, "float-right"], [3, "buttonClass", "config"]], template: function RecordGridComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordGridComponent_ng_container_0_Template, 3, 3, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.config);
        } }, dependencies: [i2.NgIf, FieldGridComponent, ActionGroupMenuComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordGridComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-grid', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"config\">\n    <div *ngIf=\"(vm$ | async) as vm\" class=\"record-grid {{(config && config.klass) || ''}}\">\n        <scrm-field-grid [actions]=\"!!config.actions\"\n                         [appendActions]=\"(config && config.appendActions) || false\"\n                         [colClass]=\"config && config.colClass\"\n                         [fieldMode]=\"mode\"\n                         [fields]=\"fields\"\n                         [record]=\"record\"\n                         [inputClass]=\"config && config.inputClass\"\n                         [labelClass]=\"config && config.labelClass\"\n                         [labelDisplay]=\"(config && config.labelDisplay) || 'top'\"\n                         [maxColumns]=\"maxColumns\"\n                         [record]=\"record\"\n                         [rowClass]=\"config && config.rowClass\"\n                         [sizeMap]=\"sizeMap\"\n                         [colAlignItems]=\"config.colAlignItems\"\n        >\n        <span *ngIf=\"config.actions\" class=\"float-right\" field-grid-actions>\n            <scrm-action-group-menu [buttonClass]=\"config.buttonClass\"\n                                    [config]=\"config.actions\"></scrm-action-group-menu>\n        </span>\n        </scrm-field-grid>\n    </div>\n</ng-container>\n" }]
    }], function () { return []; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordGridModule {
    static { this.ɵfac = function RecordGridModule_Factory(t) { return new (t || RecordGridModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordGridModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldGridModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordGridModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordGridComponent],
                exports: [
                    RecordGridComponent
                ],
                imports: [
                    CommonModule,
                    FieldGridModule,
                    ActionGroupMenuModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordGridModule, { declarations: [RecordGridComponent], imports: [CommonModule,
        FieldGridModule,
        ActionGroupMenuModule], exports: [RecordGridComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordFlexboxModule {
    static { this.ɵfac = function RecordFlexboxModule_Factory(t) { return new (t || RecordFlexboxModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordFlexboxModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            FieldModule,
            LabelModule,
            ActionGroupMenuModule,
            DynamicLabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordFlexboxModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordFlexboxComponent],
                exports: [
                    RecordFlexboxComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    FieldModule,
                    LabelModule,
                    ActionGroupMenuModule,
                    DynamicLabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordFlexboxModule, { declarations: [RecordFlexboxComponent], imports: [CommonModule,
        ButtonModule,
        FieldModule,
        LabelModule,
        ActionGroupMenuModule,
        DynamicLabelModule], exports: [RecordFlexboxComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadItemModule {
    static { this.ɵfac = function RecordThreadItemModule_Factory(t) { return new (t || RecordThreadItemModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordThreadItemModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            PanelModule,
            FieldGridModule,
            DropdownButtonModule,
            LabelModule,
            RecordGridModule,
            FieldLayoutModule,
            RecordFlexboxModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadItemModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordThreadItemComponent],
                exports: [
                    RecordThreadItemComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    PanelModule,
                    FieldGridModule,
                    DropdownButtonModule,
                    LabelModule,
                    RecordGridModule,
                    FieldLayoutModule,
                    RecordFlexboxModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordThreadItemModule, { declarations: [RecordThreadItemComponent], imports: [CommonModule,
        ButtonModule,
        PanelModule,
        FieldGridModule,
        DropdownButtonModule,
        LabelModule,
        RecordGridModule,
        FieldLayoutModule,
        RecordFlexboxModule], exports: [RecordThreadItemComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadModule {
    static { this.ɵfac = function RecordThreadModule_Factory(t) { return new (t || RecordThreadModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordThreadModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            PanelModule,
            FieldGridModule,
            DropdownButtonModule,
            LabelModule,
            RecordGridModule,
            ButtonModule,
            RecordThreadItemModule,
            LoadingSpinnerModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordThreadComponent],
                exports: [
                    RecordThreadComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    PanelModule,
                    FieldGridModule,
                    DropdownButtonModule,
                    LabelModule,
                    RecordGridModule,
                    ButtonModule,
                    RecordThreadItemModule,
                    LoadingSpinnerModule,
                    ActionGroupMenuModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordThreadModule, { declarations: [RecordThreadComponent], imports: [CommonModule,
        ButtonModule,
        PanelModule,
        FieldGridModule,
        DropdownButtonModule,
        LabelModule,
        RecordGridModule,
        ButtonModule,
        RecordThreadItemModule,
        LoadingSpinnerModule,
        ActionGroupMenuModule], exports: [RecordThreadComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NotificationsModule {
    static { this.ɵfac = function NotificationsModule_Factory(t) { return new (t || NotificationsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: NotificationsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            WidgetPanelModule,
            LabelModule,
            RecordThreadModule,
            RecordThreadItemModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationsModule, [{
        type: NgModule,
        args: [{
                declarations: [NotificationsComponent],
                exports: [
                    NotificationsComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    WidgetPanelModule,
                    LabelModule,
                    RecordThreadModule,
                    RecordThreadItemModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(NotificationsModule, { declarations: [NotificationsComponent], imports: [CommonModule,
        FieldModule,
        WidgetPanelModule,
        LabelModule,
        RecordThreadModule,
        RecordThreadItemModule], exports: [NotificationsComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SearchBarModule {
    static { this.ɵfac = function SearchBarModule_Factory(t) { return new (t || SearchBarModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SearchBarModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FormsModule,
            ImageModule,
            LabelModule,
            ReactiveFormsModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SearchBarModule, [{
        type: NgModule,
        args: [{
                declarations: [SearchBarComponent],
                exports: [SearchBarComponent],
                imports: [
                    CommonModule,
                    FormsModule,
                    ImageModule,
                    LabelModule,
                    ReactiveFormsModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SearchBarModule, { declarations: [SearchBarComponent], imports: [CommonModule,
        FormsModule,
        ImageModule,
        LabelModule,
        ReactiveFormsModule], exports: [SearchBarComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class NavbarUiModule {
    static { this.ɵfac = function NavbarUiModule_Factory(t) { return new (t || NavbarUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: NavbarUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LogoUiModule,
            LogoutUiModule,
            NgbModule,
            RouterModule,
            ImageModule,
            DynamicModule,
            LabelModule,
            FormsModule,
            NotificationsModule,
            SearchBarModule,
            RecentlyViewedComponent,
            DropdownButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NavbarUiModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    NavbarUiComponent,
                    MenuItemComponent,
                    BaseMenuItemComponent,
                    MenuRecentlyViewedComponent,
                    BaseMenuRecentlyViewedComponent,
                    SubMenuRecentlyViewedComponent,
                    BaseSubMenuRecentlyViewedComponent,
                    BaseFavoritesComponent,
                    MenuFavoritesComponent,
                    BaseMenuFavoritesComponent,
                    SubMenuFavoritesComponent,
                    BaseSubMenuFavoritesComponent,
                    HomeMenuItemComponent,
                    MenuItemLinkComponent,
                    BaseHomeMenuItemComponent,
                    BaseMenuItemLinkComponent,
                    GroupedMenuItemComponent,
                    BaseGroupedMenuItemComponent,
                    MenuItemsListComponent,
                    BaseMenuItemsListComponent,
                    BaseNavbarComponent
                ],
                exports: [
                    NavbarUiComponent,
                    MenuItemComponent,
                    BaseMenuItemComponent,
                    MenuRecentlyViewedComponent,
                    BaseMenuRecentlyViewedComponent,
                    SubMenuRecentlyViewedComponent,
                    BaseSubMenuRecentlyViewedComponent,
                    BaseFavoritesComponent,
                    MenuFavoritesComponent,
                    SubMenuFavoritesComponent,
                    BaseSubMenuFavoritesComponent,
                    HomeMenuItemComponent,
                    MenuItemLinkComponent,
                    BaseHomeMenuItemComponent,
                    BaseMenuItemLinkComponent,
                    GroupedMenuItemComponent,
                    BaseGroupedMenuItemComponent,
                    MenuItemsListComponent,
                    BaseMenuItemsListComponent,
                    BaseNavbarComponent,
                    LogoutUiComponent
                ],
                imports: [
                    CommonModule,
                    LogoUiModule,
                    LogoutUiModule,
                    NgbModule,
                    RouterModule,
                    ImageModule,
                    DynamicModule,
                    LabelModule,
                    FormsModule,
                    NotificationsModule,
                    SearchBarModule,
                    TruncatePipe,
                    RecentlyViewedComponent,
                    DropdownButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(NavbarUiModule, { declarations: [NavbarUiComponent,
        MenuItemComponent,
        BaseMenuItemComponent,
        MenuRecentlyViewedComponent,
        BaseMenuRecentlyViewedComponent,
        SubMenuRecentlyViewedComponent,
        BaseSubMenuRecentlyViewedComponent,
        BaseFavoritesComponent,
        MenuFavoritesComponent,
        BaseMenuFavoritesComponent,
        SubMenuFavoritesComponent,
        BaseSubMenuFavoritesComponent,
        HomeMenuItemComponent,
        MenuItemLinkComponent,
        BaseHomeMenuItemComponent,
        BaseMenuItemLinkComponent,
        GroupedMenuItemComponent,
        BaseGroupedMenuItemComponent,
        MenuItemsListComponent,
        BaseMenuItemsListComponent,
        BaseNavbarComponent], imports: [CommonModule,
        LogoUiModule,
        LogoutUiModule,
        NgbModule,
        RouterModule,
        ImageModule,
        DynamicModule,
        LabelModule,
        FormsModule,
        NotificationsModule,
        SearchBarModule,
        TruncatePipe,
        RecentlyViewedComponent,
        DropdownButtonModule], exports: [NavbarUiComponent,
        MenuItemComponent,
        BaseMenuItemComponent,
        MenuRecentlyViewedComponent,
        BaseMenuRecentlyViewedComponent,
        SubMenuRecentlyViewedComponent,
        BaseSubMenuRecentlyViewedComponent,
        BaseFavoritesComponent,
        MenuFavoritesComponent,
        SubMenuFavoritesComponent,
        BaseSubMenuFavoritesComponent,
        HomeMenuItemComponent,
        MenuItemLinkComponent,
        BaseHomeMenuItemComponent,
        BaseMenuItemLinkComponent,
        GroupedMenuItemComponent,
        BaseGroupedMenuItemComponent,
        MenuItemsListComponent,
        BaseMenuItemsListComponent,
        BaseNavbarComponent,
        LogoutUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function PaginationComponent_div_0_button_1_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 7);
    i0.ɵɵlistener("click", function PaginationComponent_div_0_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r7); const ctx_r6 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r6.first()); });
    i0.ɵɵelement(1, "scrm-image", 8);
    i0.ɵɵelementEnd();
} }
function PaginationComponent_div_0_button_2_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 9);
    i0.ɵɵlistener("click", function PaginationComponent_div_0_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r8 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r8.previous()); });
    i0.ɵɵelement(1, "scrm-image", 10);
    i0.ɵɵelementEnd();
} }
function PaginationComponent_div_0_button_5_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 11);
    i0.ɵɵlistener("click", function PaginationComponent_div_0_button_5_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r11); const ctx_r10 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r10.next()); });
    i0.ɵɵelement(1, "scrm-image", 12);
    i0.ɵɵelementEnd();
} }
function PaginationComponent_div_0_button_6_Template(rf, ctx) { if (rf & 1) {
    const _r13 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 13);
    i0.ɵɵlistener("click", function PaginationComponent_div_0_button_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r12.last()); });
    i0.ɵɵelement(1, "scrm-image", 14);
    i0.ɵɵelementEnd();
} }
const _c0$b = function (a0, a1) { return { "hide-pagination-count": a0, "centre-pagination": a1 }; };
function PaginationComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, PaginationComponent_div_0_button_1_Template, 2, 0, "button", 2);
    i0.ɵɵtemplate(2, PaginationComponent_div_0_button_2_Template, 2, 0, "button", 3);
    i0.ɵɵelementStart(3, "span", 4);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, PaginationComponent_div_0_button_5_Template, 2, 0, "button", 5);
    i0.ɵɵtemplate(6, PaginationComponent_div_0_button_6_Template, 2, 0, "button", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.allowPagination);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.allowPagination);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction2(9, _c0$b, ctx_r0.displayResponsiveTable, !ctx_r0.allowPagination));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate4(" (", vm_r1.pageCount.pageFirst, " - ", vm_r1.pageCount.pageLast, " ", vm_r1.appStrings["LBL_LIST_OF"] || "", " ", vm_r1.pageCount.total, ") ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.allowPagination);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.allowPagination);
} }
class PaginationComponent {
    constructor(languageStore) {
        this.languageStore = languageStore;
        this.allowPagination = true;
        this.appStrings$ = this.languageStore.appStrings$;
        this.vm$ = null;
    }
    ngOnInit() {
        const pageCount$ = this.state.getPaginationCount();
        this.vm$ = this.appStrings$.pipe(combineLatestWith(pageCount$), map(([appStrings, pageCount]) => ({ appStrings, pageCount })));
    }
    first() {
        this.state.changePage(PageSelection.FIRST);
    }
    previous() {
        this.state.changePage(PageSelection.PREVIOUS);
    }
    next() {
        this.state.changePage(PageSelection.NEXT);
    }
    last() {
        this.state.changePage(PageSelection.LAST);
    }
    static { this.ɵfac = function PaginationComponent_Factory(t) { return new (t || PaginationComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PaginationComponent, selectors: [["scrm-pagination"]], inputs: { allowPagination: "allowPagination", state: "state" }, decls: 2, vars: 3, consts: [["class", "bulk-action float-right", 4, "ngIf"], [1, "bulk-action", "float-right"], ["class", "pagination-button pagination-first", "aria-label", "Navigate to first page", 3, "click", 4, "ngIf"], ["class", "pagination-button pagination-previous", "aria-label", "Previous page", 3, "click", 4, "ngIf"], [1, "pagination-count", 3, "ngClass"], ["class", "pagination-button pagination-next", "aria-label", "Next page", 3, "click", 4, "ngIf"], ["class", "pagination-button pagination-last", "aria-label", "Navigate to last page", 3, "click", 4, "ngIf"], ["aria-label", "Navigate to first page", 1, "pagination-button", "pagination-first", 3, "click"], ["image", "paginate_first", 1, "sicon-2x", "pagination-icons"], ["aria-label", "Previous page", 1, "pagination-button", "pagination-previous", 3, "click"], ["image", "paginate_previous", 1, "sicon-2x", "pagination-icons"], ["aria-label", "Next page", 1, "pagination-button", "pagination-next", 3, "click"], ["image", "paginate_next", 1, "sicon-2x", "pagination-icons"], ["aria-label", "Navigate to last page", 1, "pagination-button", "pagination-last", 3, "click"], ["image", "paginate_last", 1, "sicon-2x", "pagination-icons"]], template: function PaginationComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, PaginationComponent_div_0_Template, 7, 12, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgClass, i2.NgIf, ImageComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaginationComponent, [{
        type: Component,
        args: [{ selector: 'scrm-pagination', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"bulk-action float-right\" *ngIf=\"(vm$ | async) as vm\">\n    <button *ngIf=\"allowPagination\" class=\"pagination-button pagination-first\"\n            aria-label=\"Navigate to first page\"\n            (click)=\"first()\">\n        <scrm-image class=\"sicon-2x pagination-icons\" image=\"paginate_first\">\n        </scrm-image>\n    </button>\n    <button *ngIf=\"allowPagination\" class=\"pagination-button pagination-previous\"\n            aria-label=\"Previous page\"\n            (click)=\"previous()\">\n        <scrm-image class=\"sicon-2x pagination-icons\" image=\"paginate_previous\">\n        </scrm-image>\n    </button>\n    <span class=\"pagination-count\"\n          [ngClass]=\"{\n            'hide-pagination-count': displayResponsiveTable, 'centre-pagination': !allowPagination\n          }\"\n    >\n      ({{vm.pageCount.pageFirst}}\n        - {{vm.pageCount.pageLast}} {{vm.appStrings['LBL_LIST_OF'] || ''}} {{vm.pageCount.total}})\n    </span>\n    <button *ngIf=\"allowPagination\" class=\"pagination-button pagination-next\"\n            aria-label=\"Next page\"\n            (click)=\"next()\">\n        <scrm-image class=\"sicon-2x pagination-icons\" image=\"paginate_next\">\n        </scrm-image>\n    </button>\n    <button *ngIf=\"allowPagination\" class=\"pagination-button pagination-last\"\n            aria-label=\"Navigate to last page\"\n            (click)=\"last()\">\n        <scrm-image class=\"sicon-2x pagination-icons\" image=\"paginate_last\">\n        </scrm-image>\n    </button>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { allowPagination: [{
            type: Input
        }], state: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PaginationModule {
    static { this.ɵfac = function PaginationModule_Factory(t) { return new (t || PaginationModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PaginationModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaginationModule, [{
        type: NgModule,
        args: [{
                declarations: [PaginationComponent],
                exports: [PaginationComponent],
                imports: [
                    CommonModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PaginationModule, { declarations: [PaginationComponent], imports: [CommonModule,
        ImageModule], exports: [PaginationComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PanelLogicActionHandler extends ActionHandler {
    shouldDisplay(data) {
        return true;
    }
    ;
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PanelLogicDisplayTypeAction extends PanelLogicActionHandler {
    constructor() {
        super();
        this.key = 'displayType';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
    }
    run(data, action) {
        const record = data.record;
        const field = data.field;
        if (!record || !field) {
            return true;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return true;
        }
        return this.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
    }
    /**
     * Check if any of the configured values is currently set
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     * @param {array} relatedAttributesFields
     * @param {object} activeOnAttributes
     */
    isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes) {
        let isActive = true;
        if (!isEmpty(activeOnFields)) {
            isActive = this.areFieldsActive(relatedFields, record, activeOnFields);
        }
        if (!isEmpty(activeOnAttributes)) {
            isActive = isActive && this.areAttributesActive(relatedAttributesFields, record, activeOnAttributes);
        }
        return isActive;
    }
    /**
     * Are attributes active
     * @param {array} relatedAttributesFields
     * @param {object} record
     * @param {object} activeOnAttributes
     */
    areAttributesActive(relatedAttributesFields, record, activeOnAttributes) {
        return relatedAttributesFields.every(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const attributes = activeOnAttributes[fieldKey] && Object.keys(activeOnAttributes[fieldKey]);
            if (!field || !attributes || !attributes.length) {
                return;
            }
            return attributes.some(attributeKey => {
                const activeValues = activeOnAttributes[fieldKey][attributeKey];
                const attribute = field.attributes && field.attributes[attributeKey];
                if (!activeValues || !activeValues.length || !attribute) {
                    return;
                }
                return this.isValueActive(attribute, activeValues);
            });
        });
    }
    /**
     * Are fields active
     * @param {array} relatedFields
     * @param {object} record
     * @param {object} activeOnFields
     */
    areFieldsActive(relatedFields, record, activeOnFields) {
        return relatedFields.every(fieldKey => {
            const fields = record.fields;
            const field = (fields && record.fields[fieldKey]) || null;
            const activeValues = activeOnFields[fieldKey];
            if (!field || !activeValues || !activeValues.length) {
                return true;
            }
            return this.isValueActive(field, activeValues);
        });
    }
    /**
     * Is value active
     * @param {object} field
     * @param {array} activeValues
     */
    isValueActive(field, activeValues) {
        let isActive = false;
        if (field.valueList && field.valueList.length) {
            field.valueList.some(value => {
                return activeValues.some(activeValue => {
                    if (activeValue === value) {
                        isActive = true;
                        return true;
                    }
                });
            });
            return isActive;
        }
        if (!isVoid(field.value)) {
            activeValues.some(activeValue => {
                if (activeValue === field.value) {
                    isActive = true;
                }
            });
        }
        return isActive;
    }
    static { this.ɵfac = function PanelLogicDisplayTypeAction_Factory(t) { return new (t || PanelLogicDisplayTypeAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PanelLogicDisplayTypeAction, factory: PanelLogicDisplayTypeAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PanelLogicDisplayTypeAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PanelLogicManager extends BaseActionManager {
    constructor(displayType) {
        super();
        displayType.modes.forEach(mode => this.actions[mode][displayType.key] = displayType);
    }
    /**
     * Run logic for the given field
     * @param {string} logicType
     * @param {object} field
     * @param {object} panel
     * @param {object} record
     * @param {object} mode
     */
    runLogic(logicType, field, panel, record, mode) {
        let toDisplay = true;
        const validModeLogic = Object.values(panel.meta.displayLogic).filter(logic => {
            const allowedModes = logic['modes'] ?? [];
            return !!(allowedModes.length && allowedModes.includes(mode));
        });
        if (!validModeLogic || !validModeLogic.length) {
            return toDisplay;
        }
        let defaultDisplay = panel.meta.display ?? 'show';
        let targetDisplay = 'hide';
        if (defaultDisplay === 'hide') {
            targetDisplay = 'show';
        }
        const context = {
            panel,
            record,
            field,
            module: record.module
        };
        const isActive = validModeLogic.some(logic => {
            const data = this.buildActionData(logic, context);
            return this.actions[mode][logic.key].run(data, logic);
        });
        if (isActive) {
            defaultDisplay = targetDisplay;
        }
        toDisplay = (defaultDisplay === 'show');
        panel.displayState.next(toDisplay);
    }
    buildActionData(action, context) {
        return {
            field: context.field,
            record: (context && context.record) || null,
            panel: context.panel || null,
        };
    }
    static { this.ɵfac = function PanelLogicManager_Factory(t) { return new (t || PanelLogicManager)(i0.ɵɵinject(PanelLogicDisplayTypeAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PanelLogicManager, factory: PanelLogicManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PanelLogicManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: PanelLogicDisplayTypeAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function PopupButtonComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0);
} }
function PopupButtonComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0, 1);
} }
const _c0$a = [[["", "popup-content", ""]], [["", "popup-title", ""]]];
const _c1$1 = ["[popup-content]", "[popup-title]"];
class PopupButtonComponent {
    constructor() {
        this.klass = 'line-action-item line-action float-right';
        this.buttonConfig = signal({});
    }
    ngOnInit() {
        this.buttonConfig.update(() => this.getButtonConfig());
    }
    getButtonConfig() {
        return {
            icon: this.icon,
            klass: this.klass,
        };
    }
    static { this.ɵfac = function PopupButtonComponent_Factory(t) { return new (t || PopupButtonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PopupButtonComponent, selectors: [["scrm-popup-button"]], inputs: { icon: "icon", klass: "klass" }, ngContentSelectors: _c1$1, decls: 5, vars: 6, consts: [["popContent", ""], ["popTitle", ""], [3, "config", "autoClose", "ngbPopover", "popoverTitle", "popoverClass", "placement"]], template: function PopupButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$a);
            i0.ɵɵtemplate(0, PopupButtonComponent_ng_template_0_Template, 1, 0, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵtemplate(2, PopupButtonComponent_ng_template_2_Template, 1, 0, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelement(4, "scrm-button", 2);
        } if (rf & 2) {
            const _r0 = i0.ɵɵreference(1);
            const _r2 = i0.ɵɵreference(3);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("config", ctx.buttonConfig())("autoClose", "outside")("ngbPopover", _r0)("popoverTitle", _r2)("popoverClass", "popover-wrapper")("placement", "right");
        } }, dependencies: [ButtonComponent, i3$1.NgbPopover], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PopupButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-popup-button', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-template #popContent>\n    <ng-content select=\"[popup-content]\"></ng-content>\n</ng-template>\n<ng-template #popTitle>\n    <ng-content select=\"[popup-title]\"></ng-content>\n</ng-template>\n<scrm-button [config]=\"buttonConfig()\"\n             [autoClose]=\"'outside'\"\n             [ngbPopover]=\"popContent\"\n             [popoverTitle]=\"popTitle\"\n             [popoverClass]=\"'popover-wrapper'\"\n             [placement]=\"'right'\"\n></scrm-button>\n" }]
    }], function () { return []; }, { icon: [{
            type: Input
        }], klass: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class PopupButtonModule {
    static { this.ɵfac = function PopupButtonModule_Factory(t) { return new (t || PopupButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: PopupButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            NgbPopoverModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PopupButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [PopupButtonComponent],
                exports: [PopupButtonComponent],
                imports: [
                    CommonModule,
                    ButtonModule,
                    NgbPopoverModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(PopupButtonModule, { declarations: [PopupButtonComponent], imports: [CommonModule,
        ButtonModule,
        NgbPopoverModule], exports: [PopupButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordDetailsPopupButtonComponent_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 4)(1, "div", 5);
    i0.ɵɵelement(2, "scrm-label", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 7);
    i0.ɵɵelement(4, "scrm-field", 8);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const column_r2 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", column_r2.label)("module", ctx_r1.record.module);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("mode", "list")("field", ctx_r1.getField(column_r2, ctx_r1.record))("type", column_r2.type)("record", ctx_r1.record);
} }
function RecordDetailsPopupButtonComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵtemplate(1, RecordDetailsPopupButtonComponent_div_1_div_1_Template, 5, 6, "div", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r0.columns);
} }
class RecordDetailsPopupButtonComponent {
    constructor(fieldManager) {
        this.fieldManager = fieldManager;
    }
    getField(column, record) {
        if (!column || !record) {
            return null;
        }
        return this.fieldManager.addField(record, column);
    }
    static { this.ɵfac = function RecordDetailsPopupButtonComponent_Factory(t) { return new (t || RecordDetailsPopupButtonComponent)(i0.ɵɵdirectiveInject(FieldManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordDetailsPopupButtonComponent, selectors: [["scrm-record-details-popup-button"]], inputs: { record: "record", columns: "columns" }, decls: 2, vars: 2, consts: [[3, "icon"], ["popup-content", "", "class", "container container-popover scrollbar-thin", 4, "ngIf"], ["popup-content", "", 1, "container", "container-popover", "scrollbar-thin"], ["class", "row py-1", 4, "ngFor", "ngForOf"], [1, "row", "py-1"], [1, "col", "font-weight-bold", "text-muted"], [3, "labelKey", "module"], [1, "col"], [3, "mode", "field", "type", "record"]], template: function RecordDetailsPopupButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-popup-button", 0);
            i0.ɵɵtemplate(1, RecordDetailsPopupButtonComponent_div_1_Template, 2, 1, "div", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("icon", "dots-vertical");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.columns);
        } }, dependencies: [i2.NgForOf, i2.NgIf, PopupButtonComponent, FieldComponent, LabelComponent], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordDetailsPopupButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-details-popup-button', changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-popup-button [icon]=\"'dots-vertical'\">\n    <div popup-content *ngIf=\"columns\" class=\"container container-popover scrollbar-thin\">\n        <div *ngFor=\"let column of columns\" class=\"row py-1\">\n            <div class=\"col font-weight-bold text-muted\">\n                <scrm-label [labelKey]=\"column.label\" [module]=\"record.module\"></scrm-label>\n            </div>\n            <div class=\"col\">\n                <scrm-field [mode]=\"'list'\"\n                            [field]=\"getField(column, record)\"\n                            [type]=\"column.type\"\n                            [record]=\"record\">\n                </scrm-field>\n            </div>\n        </div>\n    </div>\n</scrm-popup-button>\n" }]
    }], function () { return [{ type: FieldManager }]; }, { record: [{
            type: Input
        }], columns: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordDetailsPopupButtonModule {
    static { this.ɵfac = function RecordDetailsPopupButtonModule_Factory(t) { return new (t || RecordDetailsPopupButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordDetailsPopupButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            PopupButtonModule,
            FieldModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordDetailsPopupButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordDetailsPopupButtonComponent],
                exports: [RecordDetailsPopupButtonComponent],
                imports: [
                    CommonModule,
                    PopupButtonModule,
                    FieldModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordDetailsPopupButtonModule, { declarations: [RecordDetailsPopupButtonComponent], imports: [CommonModule,
        PopupButtonModule,
        FieldModule,
        LabelModule], exports: [RecordDetailsPopupButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ToObservablePipe {
    transform(value) {
        return of(value);
    }
    static { this.ɵfac = function ToObservablePipe_Factory(t) { return new (t || ToObservablePipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "toObservable", type: ToObservablePipe, pure: true }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToObservablePipe, [{
        type: Pipe,
        args: [{
                name: 'toObservable'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordContentComponent_ng_container_0_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5)(1, "div", 6)(2, "scrm-panel", 7);
    i0.ɵɵpipe(3, "toObservable");
    i0.ɵɵelementStart(4, "div", 8);
    i0.ɵɵelement(5, "scrm-field-layout", 9);
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const panel_r4 = ctx.$implicit;
    const ctx_r3 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("title", panel_r4.label)("isCollapsed$", i0.ɵɵpipeBind1(3, 6, panel_r4.isCollapsed));
    i0.ɵɵadvance(2);
    i0.ɵɵclassMapInterpolate1("panel-", panel_r4.key, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("dataSource", ctx_r3.getLayoutDataSource(panel_r4));
} }
function RecordContentComponent_ng_container_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_1_div_1_Template, 6, 8, "div", 4);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r1.panels);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_li_1_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "scrm-field-layout", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const panel_r8 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r13 = i0.ɵɵnextContext(3);
    i0.ɵɵclassMapInterpolate1("tab-", panel_r8.key, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("dataSource", ctx_r13.getLayoutDataSource(panel_r8));
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_li_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "li", 17)(1, "a", 18);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_li_1_ng_template_3_Template, 2, 4, "ng-template", 19);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r15 = i0.ɵɵnextContext(2);
    const i_r9 = ctx_r15.index;
    const panel_r8 = ctx_r15.$implicit;
    i0.ɵɵproperty("ngbNavItem", i_r9 + 1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(panel_r8.label);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_li_1_Template, 4, 2, "li", 16);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const panelDisplay_r11 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !!panelDisplay_r11);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_4_ng_container_1_Template, 2, 1, "ng-container", 0);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const panel_r8 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 1, panel_r8.display$));
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6)(1, "scrm-panel", 7);
    i0.ɵɵpipe(2, "toObservable");
    i0.ɵɵelementStart(3, "div", 8);
    i0.ɵɵelement(4, "scrm-field-layout", 9);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const panel_r20 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r24 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("title", panel_r20.label)("isCollapsed$", i0.ɵɵpipeBind1(2, 6, panel_r20.isCollapsed));
    i0.ɵɵadvance(2);
    i0.ɵɵclassMapInterpolate1("panel-", panel_r20.key, "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("dataSource", ctx_r24.getLayoutDataSource(panel_r20));
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_div_1_div_1_Template, 5, 8, "div", 22);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const j_r18 = i0.ɵɵnextContext(3).index;
    const ctx_r23 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", j_r18 == ctx_r23.active - 1);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_div_1_Template, 2, 1, "div", 20);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const panelDisplay_r22 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !!panelDisplay_r22);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_ng_container_1_Template, 2, 1, "ng-container", 0);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const panel_r20 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 1, panel_r20.display$));
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_div_1_Template, 3, 3, "div", 14);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const panel_r17 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", panel_r17.subPanels);
} }
function RecordContentComponent_ng_container_0_div_2_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_2_ng_container_7_ng_container_1_Template, 2, 1, "ng-container", 14);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r7.panels);
} }
function RecordContentComponent_ng_container_0_div_2_Template(rf, ctx) { if (rf & 1) {
    const _r28 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 10)(1, "div", 11)(2, "ul", 12, 13);
    i0.ɵɵlistener("activeIdChange", function RecordContentComponent_ng_container_0_div_2_Template_ul_activeIdChange_2_listener($event) { i0.ɵɵrestoreView(_r28); const ctx_r27 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r27.active = $event); });
    i0.ɵɵtemplate(4, RecordContentComponent_ng_container_0_div_2_ng_container_4_Template, 3, 3, "ng-container", 14);
    i0.ɵɵelementEnd();
    i0.ɵɵprojection(5);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(6, "div", 15);
    i0.ɵɵtemplate(7, RecordContentComponent_ng_container_0_div_2_ng_container_7_Template, 2, 1, "ng-container", 0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const _r5 = i0.ɵɵreference(3);
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("activeId", ctx_r2.active);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r2.panels);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngbNavOutlet", _r5);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.panelsInPrevTab && ctx_r2.panelsInPrevTab.length);
} }
function RecordContentComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContentComponent_ng_container_0_div_1_Template, 2, 1, "div", 1);
    i0.ɵɵtemplate(2, RecordContentComponent_ng_container_0_div_2_Template, 8, 4, "div", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.config && ctx_r0.config.layout === "panels");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.config && ctx_r0.config.layout === "tabs");
} }
const _c0$9 = [[["", "top-right-placement", ""]]];
const _c1 = ["[top-right-placement]"];
class RecordContentComponent {
    constructor(language) {
        this.language = language;
        this.config = {};
        this.panelsInPrevTab = [];
        this.active = 1;
        this.subs = [];
    }
    ngOnInit() {
        this.subs.push(this.dataSource.getDisplayConfig().subscribe(config => {
            this.config = { ...config };
        }));
        this.subs.push(this.dataSource.getPanels().subscribe(panels => {
            this.panels = [...panels];
            if (this?.config?.layout === 'panels') {
                this.updatePanelCollapseState();
            }
            else {
                this.updatePanelsInTabs();
            }
        }));
        this.subs.push(this.dataSource.getRecord().subscribe(record => {
            this.record = { ...record };
            this.fields = record.fields;
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    updatePanelsInTabs() {
        let tempPanels = [];
        let prevTabKey = '';
        const panelsMap = this.buildPanelMap();
        const tabDefs = this.mapTabDefs();
        Object.keys(tabDefs).forEach(tabDefKey => {
            const tabDef = tabDefs[tabDefKey];
            if (isTrue(tabDef.newTab)) {
                tempPanels = [...tempPanels, panelsMap[tabDefKey]];
                prevTabKey = tabDefKey;
            }
            else {
                const prevTab = tabDefs[prevTabKey];
                const panel = panelsMap[prevTabKey];
                if (!this.panelsInPrevTab.includes(panel)) {
                    this.panelsInPrevTab.push(panel);
                }
                const panelToAdd = panelsMap[tabDefKey];
                if (isTrue(prevTab?.newTab) && this.panelsInPrevTab.length > 0) {
                    this.addToPrevTab(panelToAdd);
                }
            }
        });
        this.panels = tempPanels;
    }
    addToPrevTab(panelToAdd) {
        const index = this.panelsInPrevTab.length - 1;
        if (!(this.panelsInPrevTab[index]?.subPanels ?? null)) {
            this.panelsInPrevTab[index].subPanels = [];
        }
        this.panelsInPrevTab[index].subPanels.push(panelToAdd);
    }
    updatePanelCollapseState() {
        const panelMap = this.buildPanelMap();
        this.panels.forEach(panel => {
            const panelKey = panel.key.toUpperCase();
            if (panelMap[panelKey]) {
                panel.isCollapsed = panelMap[panelKey].isCollapsed;
            }
        });
    }
    buildPanelMap() {
        const panelMap = {};
        this.panels.forEach(panel => {
            let isCollapsed = false;
            panel.label = panel?.label?.toUpperCase() ?? '';
            const panelKey = panel?.key?.toUpperCase() ?? '';
            if (panel.meta.panelDefault === 'collapsed') {
                isCollapsed = true;
            }
            panel.isCollapsed = isCollapsed;
            panelMap[panelKey] = panel;
        });
        return panelMap;
    }
    mapTabDefs() {
        const tabDefs = {};
        Object.keys(this?.config?.tabDefs ?? {}).forEach(key => {
            tabDefs[key.toUpperCase()] = this?.config?.tabDefs[key];
        });
        return tabDefs;
    }
    getLayoutDataSource(panel) {
        return {
            inlineEdit: true,
            getConfig: () => this.dataSource.getDisplayConfig().pipe(map(config => ({
                mode: config.mode,
                maxColumns: config.maxColumns,
            }))),
            getLayout: () => of(panel).pipe(shareReplay(1)),
            getFields: () => this.dataSource.getRecord().pipe(map(record => (record.fields))),
            getRecord: () => this.dataSource.getRecord(),
            getEditAction: () => this.dataSource.getEditAction()
        };
    }
    static { this.ɵfac = function RecordContentComponent_Factory(t) { return new (t || RecordContentComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordContentComponent, selectors: [["scrm-record-content"]], inputs: { dataSource: "dataSource" }, ngContentSelectors: _c1, decls: 1, vars: 1, consts: [[4, "ngIf"], ["class", "record-content panel-layout container-fluid pl-0 pr-0", 4, "ngIf"], ["class", "record-content tabs-layout container-fluid pl-0 pr-0", 4, "ngIf"], [1, "record-content", "panel-layout", "container-fluid", "pl-0", "pr-0"], ["class", "row no-gutters mb-3", 4, "ngFor", "ngForOf"], [1, "row", "no-gutters", "mb-3"], [1, "col"], ["mode", "collapsible", 3, "title", "isCollapsed$"], ["panel-body", ""], [3, "dataSource"], [1, "record-content", "tabs-layout", "container-fluid", "pl-0", "pr-0"], [1, "d-flex", "flex-column", "flex-column-reverse", "flex-sm-row", "justify-content-between"], ["ngbNav", "", 1, "nav-tabs", 3, "activeId", "activeIdChange"], ["nav", "ngbNav"], [4, "ngFor", "ngForOf"], [1, "p-2", "pt-3", "rounded-right", "rounded-bottom", 3, "ngbNavOutlet"], ["class", "tab", 3, "ngbNavItem", 4, "ngIf"], [1, "tab", 3, "ngbNavItem"], ["ngbNavLink", "", 1, "tab-link"], ["ngbNavContent", ""], ["class", "row no-gutters mt-3", 4, "ngIf"], [1, "row", "no-gutters", "mt-3"], ["class", "col", 4, "ngIf"]], template: function RecordContentComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0$9);
            i0.ɵɵtemplate(0, RecordContentComponent_ng_container_0_Template, 3, 2, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.dataSource);
        } }, dependencies: [i2.NgForOf, i2.NgIf, PanelComponent, i3$1.NgbNavContent, i3$1.NgbNav, i3$1.NgbNavItem, i3$1.NgbNavItemRole, i3$1.NgbNavLink, i3$1.NgbNavLinkBase, i3$1.NgbNavOutlet, FieldLayoutComponent, i2.AsyncPipe, ToObservablePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContentComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-content', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"dataSource\">\n    <div *ngIf=\"config && config.layout === 'panels'\" class=\"record-content panel-layout container-fluid pl-0 pr-0\">\n        <div class=\"row no-gutters mb-3\" *ngFor=\"let panel of panels\">\n            <div class=\"col\">\n                <scrm-panel [title]=\"panel.label\" [isCollapsed$]=\"(panel.isCollapsed | toObservable)\" mode=\"collapsible\">\n                    <div panel-body class=\"panel-{{panel.key}}\">\n                        <scrm-field-layout [dataSource]=\"getLayoutDataSource(panel)\"></scrm-field-layout>\n                    </div>\n                </scrm-panel>\n            </div>\n        </div>\n\n    </div>\n\n    <div *ngIf=\"config && config.layout === 'tabs'\" class=\"record-content tabs-layout container-fluid pl-0 pr-0\">\n        <div class=\"d-flex flex-column flex-column-reverse flex-sm-row justify-content-between\">\n            <ul ngbNav #nav=\"ngbNav\" class=\"nav-tabs\" [(activeId)]=\"active\">\n                <ng-container *ngFor=\"let panel of panels; index as i;\">\n                    <ng-container *ngIf=\"(panel.display$ | async) as panelDisplay\">\n                        <li class=\"tab\" [ngbNavItem]=\"i+1\" *ngIf=\"!!panelDisplay\">\n                            <a class=\"tab-link\" ngbNavLink>{{panel.label}}</a>\n                            <ng-template ngbNavContent>\n                                <div class=\"tab-{{panel.key}}\">\n                                    <scrm-field-layout [dataSource]=\"getLayoutDataSource(panel)\"></scrm-field-layout>\n                                </div>\n                            </ng-template>\n                        </li>\n                    </ng-container>\n                </ng-container>\n            </ul>\n            <ng-content select=\"[top-right-placement]\"></ng-content>\n        </div>\n\n        <div [ngbNavOutlet]=\"nav\" class=\"p-2 pt-3 rounded-right rounded-bottom\"></div>\n\n\n        <ng-container *ngIf=\"panelsInPrevTab && panelsInPrevTab.length\">\n            <ng-container *ngFor=\"let panel of panels; let j = index;\">\n                <div *ngFor=\"let panel of panel.subPanels;\">\n                    <ng-container *ngIf=\"(panel.display$ | async) as panelDisplay\">\n                        <div class=\"row no-gutters mt-3\" *ngIf=\"!!panelDisplay\">\n                            <div class=\"col\" *ngIf=\"j==active-1\">\n                                <scrm-panel [title]=\"panel.label\" [isCollapsed$]=\"(panel.isCollapsed | toObservable)\" mode=\"collapsible\">\n                                    <div panel-body class=\"panel-{{panel.key}}\">\n                                        <scrm-field-layout [dataSource]=\"getLayoutDataSource(panel)\"></scrm-field-layout>\n                                    </div>\n                                </scrm-panel>\n                            </div>\n                        </div>\n                    </ng-container>\n                </div>\n            </ng-container>\n        </ng-container>\n\n    </div>\n\n</ng-container>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { dataSource: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ToObservableModule {
    static { this.ɵfac = function ToObservableModule_Factory(t) { return new (t || ToObservableModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ToObservableModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToObservableModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    ToObservablePipe
                ],
                exports: [
                    ToObservablePipe
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ToObservableModule, { declarations: [ToObservablePipe], imports: [CommonModule], exports: [ToObservablePipe] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordContentModule {
    static { this.ɵfac = function RecordContentModule_Factory(t) { return new (t || RecordContentModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordContentModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            PanelModule,
            NgbModule,
            FieldLayoutModule,
            ToObservableModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContentModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    RecordContentComponent
                ],
                exports: [
                    RecordContentComponent
                ],
                imports: [
                    CommonModule,
                    PanelModule,
                    NgbModule,
                    FieldLayoutModule,
                    ToObservableModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordContentModule, { declarations: [RecordContentComponent], imports: [CommonModule,
        PanelModule,
        NgbModule,
        FieldLayoutModule,
        ToObservableModule], exports: [RecordContentComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordContentSkeletonComponent {
    constructor() {
    }
    ngOnInit() {
    }
    static { this.ɵfac = function RecordContentSkeletonComponent_Factory(t) { return new (t || RecordContentSkeletonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordContentSkeletonComponent, selectors: [["scrm-record-content-skeleton"]], decls: 138, vars: 0, consts: [[1, "record-content", "tabs-layout", "container-fluid", "pl-0", "pr-0", "record-content-skeleton"], [1, "nav-tabs", "nav"], [1, "tab", "nav-item"], ["href", "", 1, "tab-link", "nav-link", "active", "pl-5", "pr-5", "h-100", "box-loading"], ["href", "", 1, "tab-link", "nav-link", "pl-5", "pr-5", "h-100", "box-loading"], [1, "p-2", "pt-3", "rounded-right", "rounded-bottom", "tab-content"], [1, "tab-pane", "fade", "active", "show"], [1, ""], [1, "detail", "field-layout"], [1, "form-row", "align-items-center", "pt-1", "pb-1"], [1, "field-column-bordered", "col", "form-group", "m-0", "pl-3", "pb-2", "pr-3"], [1, "label-container"], [1, "col-form-label-sm", "mb-0", "pb-3", "pl-5", "pr-5", "h-100", "rounded", "box-loading"], [1, "d-flex"], [1, "flex-grow-1", "text-break", "rounded", "box-loading", "skeleton-field-content"], ["type", "button", 1, "record-action-button"], ["image", "pencil"], [1, "field-separation", "mt-2"], [1, "col", "form-group", "m-0", "pl-3", "pb-2", "pr-3"]], template: function RecordContentSkeletonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "ul", 1)(2, "li", 2);
            i0.ɵɵelement(3, "a", 3);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(4, "li", 2);
            i0.ɵɵelement(5, "a", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "li", 2);
            i0.ɵɵelement(7, "a", 4);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(8, "div", 5)(9, "div", 6)(10, "div", 7)(11, "form", 8)(12, "div", 9)(13, "div", 10)(14, "div", 11)(15, "strong");
            i0.ɵɵelement(16, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(17, "div", 13);
            i0.ɵɵelement(18, "div", 14);
            i0.ɵɵelementStart(19, "div")(20, "button", 15);
            i0.ɵɵelement(21, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(22, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(23, "div", 18)(24, "div", 11)(25, "strong");
            i0.ɵɵelement(26, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(27, "div", 13);
            i0.ɵɵelement(28, "div", 14);
            i0.ɵɵelementStart(29, "div")(30, "button", 15);
            i0.ɵɵelement(31, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(32, "div", 17);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(33, "div", 9)(34, "div", 10)(35, "div", 11)(36, "strong");
            i0.ɵɵelement(37, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(38, "div", 13);
            i0.ɵɵelement(39, "div", 14);
            i0.ɵɵelementStart(40, "div")(41, "button", 15);
            i0.ɵɵelement(42, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(43, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(44, "div", 18)(45, "div", 11)(46, "strong");
            i0.ɵɵelement(47, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(48, "div", 13);
            i0.ɵɵelement(49, "div", 14);
            i0.ɵɵelementStart(50, "div")(51, "button", 15);
            i0.ɵɵelement(52, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(53, "div", 17);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(54, "div", 9)(55, "div", 10)(56, "div", 11)(57, "strong");
            i0.ɵɵelement(58, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(59, "div", 13);
            i0.ɵɵelement(60, "div", 14);
            i0.ɵɵelementStart(61, "div")(62, "button", 15);
            i0.ɵɵelement(63, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(64, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(65, "div", 18)(66, "div", 11)(67, "strong");
            i0.ɵɵelement(68, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(69, "div", 13);
            i0.ɵɵelement(70, "div", 14);
            i0.ɵɵelementStart(71, "div")(72, "button", 15);
            i0.ɵɵelement(73, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(74, "div", 17);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(75, "div", 9)(76, "div", 10)(77, "div", 11)(78, "strong");
            i0.ɵɵelement(79, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(80, "div", 13);
            i0.ɵɵelement(81, "div", 14);
            i0.ɵɵelementStart(82, "div")(83, "button", 15);
            i0.ɵɵelement(84, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(85, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(86, "div", 18)(87, "div", 11)(88, "strong");
            i0.ɵɵelement(89, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(90, "div", 13);
            i0.ɵɵelement(91, "div", 14);
            i0.ɵɵelementStart(92, "div")(93, "button", 15);
            i0.ɵɵelement(94, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(95, "div", 17);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(96, "div", 9)(97, "div", 10)(98, "div", 11)(99, "strong");
            i0.ɵɵelement(100, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(101, "div", 13);
            i0.ɵɵelement(102, "div", 14);
            i0.ɵɵelementStart(103, "div")(104, "button", 15);
            i0.ɵɵelement(105, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(106, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(107, "div", 18)(108, "div", 11)(109, "strong");
            i0.ɵɵelement(110, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(111, "div", 13);
            i0.ɵɵelement(112, "div", 14);
            i0.ɵɵelementStart(113, "div")(114, "button", 15);
            i0.ɵɵelement(115, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(116, "div", 17);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(117, "div", 9)(118, "div", 10)(119, "div", 11)(120, "strong");
            i0.ɵɵelement(121, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(122, "div", 13);
            i0.ɵɵelement(123, "div", 14);
            i0.ɵɵelementStart(124, "div")(125, "button", 15);
            i0.ɵɵelement(126, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(127, "div", 17);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(128, "div", 18)(129, "div", 11)(130, "strong");
            i0.ɵɵelement(131, "label", 12);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(132, "div", 13);
            i0.ɵɵelement(133, "div", 14);
            i0.ɵɵelementStart(134, "div")(135, "button", 15);
            i0.ɵɵelement(136, "scrm-image", 16);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelement(137, "div", 17);
            i0.ɵɵelementEnd()()()()()()();
        } }, dependencies: [ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContentSkeletonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-content-skeleton', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"record-content tabs-layout container-fluid pl-0 pr-0 record-content-skeleton\">\n    <ul class=\"nav-tabs nav\">\n        <li class=\"tab nav-item\">\n            <a class=\"tab-link nav-link active pl-5 pr-5 h-100 box-loading\" href=\"\">\n            </a>\n        </li>\n        <li class=\"tab nav-item\">\n            <a class=\"tab-link nav-link pl-5 pr-5 h-100 box-loading\" href=\"\">\n            </a>\n        </li>\n        <li class=\"tab nav-item\">\n            <a class=\"tab-link nav-link pl-5 pr-5 h-100 box-loading\" href=\"\">\n            </a>\n        </li>\n    </ul>\n    <div class=\"p-2 pt-3 rounded-right rounded-bottom tab-content\">\n        <div class=\"tab-pane fade active show\">\n            <div class=\"\">\n                <form class=\"detail field-layout\">\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\">\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                    <div class=\"form-row align-items-center pt-1 pb-1\">\n                        <div class=\"field-column-bordered col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                        <div class=\"col form-group m-0 pl-3 pb-2 pr-3\">\n                            <div class=\"label-container\">\n                                <strong>\n                                    <label class=\"col-form-label-sm mb-0 pb-3 pl-5 pr-5 h-100 rounded box-loading\">\n                                    </label>\n                                </strong>\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break rounded box-loading skeleton-field-content\"\n                                >\n                                </div>\n                                <div>\n                                    <button class=\"record-action-button\" type=\"button\">\n                                        <scrm-image image=\"pencil\">\n                                        </scrm-image>\n                                    </button>\n                                </div>\n                            </div>\n                            <div class=\"field-separation mt-2\"></div>\n                        </div>\n                    </div>\n                </form>\n            </div>\n        </div>\n    </div>\n</div>\n" }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordContentSkeletonModule {
    static { this.ɵfac = function RecordContentSkeletonModule_Factory(t) { return new (t || RecordContentSkeletonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordContentSkeletonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContentSkeletonModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    RecordContentSkeletonComponent
                ],
                exports: [
                    RecordContentSkeletonComponent
                ],
                imports: [
                    CommonModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordContentSkeletonModule, { declarations: [RecordContentSkeletonComponent], imports: [CommonModule,
        ImageModule], exports: [RecordContentSkeletonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function MobileMenuComponent_ng_container_1_li_2_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 6);
    i0.ɵɵlistener("click", function MobileMenuComponent_ng_container_1_li_2_Template_li_click_0_listener() { const restoredCtx = i0.ɵɵrestoreView(_r5); const item_r3 = restoredCtx.$implicit; const ctx_r4 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r4.navigateRoute(item_r3 == null ? null : item_r3.link == null ? null : item_r3.link.route)); });
    i0.ɵɵelement(1, "scrm-image", 7);
    i0.ɵɵelementStart(2, "a", 8);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r3 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("image", item_r3.icon);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(item_r3.link.label);
} }
function MobileMenuComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 4);
    i0.ɵɵtemplate(2, MobileMenuComponent_ng_container_1_li_2_Template, 4, 2, "li", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", ctx_r0.menuItems());
} }
function MobileMenuComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "scrm-label", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", "LBL_MODULE_NOT_FOUND");
} }
class MobileMenuComponent {
    constructor(router, appStateStore) {
        this.router = router;
        this.appStateStore = appStateStore;
        this.menuItems = signal([]);
    }
    ngOnInit() {
    }
    navigateRoute(route) {
        this.router.navigate([route]).then();
        this.appStateStore.toggleSidebar();
    }
    static { this.ɵfac = function MobileMenuComponent_Factory(t) { return new (t || MobileMenuComponent)(i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(AppStateStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MobileMenuComponent, selectors: [["scrm-mobile-menu"]], inputs: { menuItems: "menuItems" }, standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 4, vars: 2, consts: [[1, "mobile-menu-container"], [4, "ngIf"], [1, "border-0"], ["class", "d-flex justify-content-center", 4, "ngIf"], [1, "mobile-menu-items", "scrollbar-thin"], ["class", "d-flex align-items-center", 3, "click", 4, "ngFor", "ngForOf"], [1, "d-flex", "align-items-center", 3, "click"], [1, "sicon", "mobile-nav-icon", "pl-3", 3, "image"], [1, "flex-grow-1", "mobile-nav-link", "px-3", "py-2", "mobile-menu-item-label"], [1, "d-flex", "justify-content-center"], [3, "labelKey"]], template: function MobileMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, MobileMenuComponent_ng_container_1_Template, 3, 1, "ng-container", 1);
            i0.ɵɵelementStart(2, "li", 2);
            i0.ɵɵtemplate(3, MobileMenuComponent_div_3_Template, 2, 1, "div", 3);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            let tmp_1_0;
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.menuItems() && ctx.menuItems().length);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", !ctx.menuItems() || !((tmp_1_0 = ctx.menuItems()) == null ? null : tmp_1_0.length));
        } }, dependencies: [CommonModule, i2.NgForOf, i2.NgIf, RouterModule, SearchBarModule, ImageModule, ImageComponent, LabelModule, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MobileMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-mobile-menu', standalone: true, imports: [CommonModule, RouterModule, SearchBarModule, ImageModule, LabelModule], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2024 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"mobile-menu-container\">\n    <ng-container *ngIf=\"menuItems() && menuItems().length\">\n        <div class=\"mobile-menu-items scrollbar-thin\">\n            <li class=\"d-flex align-items-center\" (click)=\"navigateRoute(item?.link?.route)\" *ngFor=\"let item of menuItems()\">\n                <scrm-image class=\"sicon mobile-nav-icon pl-3\" [image]=\"item.icon\"\n               ></scrm-image>\n                <a class=\"flex-grow-1 mobile-nav-link px-3 py-2 mobile-menu-item-label\">{{ item.link.label }}</a>\n            </li>\n        </div>\n    </ng-container>\n\n    <li class=\"border-0\">\n        <div *ngIf=\"!menuItems() || !menuItems()?.length\" class=\"d-flex justify-content-center\">\n            <scrm-label [labelKey]=\"'LBL_MODULE_NOT_FOUND'\"></scrm-label>\n        </div>\n    </li>\n</div>\n\n\n" }]
    }], function () { return [{ type: i1$2.Router }, { type: AppStateStore }]; }, { menuItems: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$8 = ["searchBarComponent"];
function SidebarComponent_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 3)(1, "div", 4)(2, "button", 5);
    i0.ɵɵlistener("click", function SidebarComponent_ng_template_1_Template_button_click_2_listener() { i0.ɵɵrestoreView(_r4); const ctx_r3 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r3.toggleSidebar()); });
    i0.ɵɵelement(3, "scrm-image", 6);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(4, "div", 7)(5, "scrm-search-bar", 8, 9);
    i0.ɵɵlistener("searchExpression", function SidebarComponent_ng_template_1_Template_scrm_search_bar_searchExpression_5_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r5 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r5.search($event)); });
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("labelKey", "LBL_FILTER_MODULES")("klass", "search-bar-mobile-menu")("searchTrigger", "input");
} }
function SidebarComponent_ng_template_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-mobile-menu", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("menuItems", ctx_r6.displayedItems);
} }
function SidebarComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵtemplate(1, SidebarComponent_ng_template_2_ng_container_1_Template, 2, 1, "ng-container", 11);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.displayedItems());
} }
class SidebarComponent {
    constructor(appStateStore, navigationStore, moduleNameMapper, moduleNavigation, language) {
        this.appStateStore = appStateStore;
        this.navigationStore = navigationStore;
        this.moduleNameMapper = moduleNameMapper;
        this.moduleNavigation = moduleNavigation;
        this.language = language;
        this.isSidebarVisible = false;
        this.menuItems = [];
        this.displayedItems = signal([]);
        this.subs = [];
    }
    ngOnInit() {
        this.subs.push(this.navigationStore.vm$.pipe(combineLatestWith(this.language.vm$), map(([navigation, language]) => {
            this.setMenuItems(navigation.modules, navigation.tabs, language.appListStrings);
        })).subscribe());
        this.subs.push(this.appStateStore.isSidebarVisible$.subscribe((isSidebarVisible) => {
            this.isSidebarVisible = isSidebarVisible;
            if (!this.isSidebarVisible) {
                this.clearFilter();
            }
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    setMenuItems(modules, tabs, appListStrings) {
        const menuItems = [];
        tabs.forEach((tab) => {
            const moduleInfo = modules[tab];
            const moduleRoute = this.moduleNavigation.getModuleRoute(moduleInfo);
            const menuItem = {
                link: {
                    label: this.moduleNavigation.getModuleLabel(moduleInfo, appListStrings),
                    url: moduleRoute.url,
                    route: moduleRoute.route,
                    params: null
                },
                icon: this.moduleNameMapper.toLegacy(moduleInfo?.name) ?? null,
                submenu: [],
                module: moduleInfo?.name ?? null
            };
            menuItems.push(menuItem);
        });
        this.menuItems = [...menuItems];
        this.displayedItems.set([...menuItems]);
    }
    toggleSidebar() {
        this.appStateStore.toggleSidebar();
    }
    closeSidebar() {
        this.clearFilter();
        this.appStateStore.closeSidebar();
    }
    search(searchTerm) {
        this.displayedItems.set([]);
        if (searchTerm.length && searchTerm.trim() !== '') {
            this.displayedItems.set(this.menuItems.filter(item => {
                return item?.link?.label.toLowerCase().includes(searchTerm.toLowerCase());
            }) ?? []);
        }
        else {
            this.resetMenuItems();
        }
    }
    resetMenuItems() {
        this.displayedItems.set([...this.menuItems]);
    }
    clearFilter() {
        this.resetMenuItems();
        this?.searchBarComponent?.clearSearchTerm();
    }
    static { this.ɵfac = function SidebarComponent_Factory(t) { return new (t || SidebarComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(NavigationStore), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SidebarComponent, selectors: [["scrm-sidebar"]], viewQuery: function SidebarComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$8, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.searchBarComponent = _t.first);
        } }, standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 2, consts: [[3, "visible", "showCloseIcon", "visibleChange", "onHide"], ["pTemplate", "header"], ["pTemplate", "content"], [1, "d-flex", "justify-content-start"], [1, "flex-shrink-1"], ["type", "button", 1, "navbar-toggler", 3, "click"], ["image", "hamburger", 1, "responsive-menu-toggler"], [1, "d-flex", "flex-grow-1", "justify-content-center"], [3, "labelKey", "klass", "searchTrigger", "searchExpression"], ["searchBarComponent", ""], [1, "sidebar-container"], [4, "ngIf"], [3, "menuItems"]], template: function SidebarComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "p-sidebar", 0);
            i0.ɵɵlistener("visibleChange", function SidebarComponent_Template_p_sidebar_visibleChange_0_listener($event) { return ctx.isSidebarVisible = $event; })("onHide", function SidebarComponent_Template_p_sidebar_onHide_0_listener() { return ctx.closeSidebar(); });
            i0.ɵɵtemplate(1, SidebarComponent_ng_template_1_Template, 7, 3, "ng-template", 1);
            i0.ɵɵtemplate(2, SidebarComponent_ng_template_2_Template, 2, 1, "ng-template", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("visible", ctx.isSidebarVisible)("showCloseIcon", false);
        } }, dependencies: [CommonModule, i2.NgIf, SidebarModule, i7$1.Sidebar, i7.PrimeTemplate, ImageModule, ImageComponent, MobileMenuComponent, SearchBarModule, SearchBarComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarComponent, [{
        type: Component,
        args: [{ selector: 'scrm-sidebar', standalone: true, imports: [CommonModule, SidebarModule, ImageModule, MobileMenuComponent, SearchBarModule], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2024 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<p-sidebar [(visible)]=\"isSidebarVisible\" [showCloseIcon]=\"false\" (onHide)=\"closeSidebar()\">\n    <ng-template pTemplate=\"header\">\n        <div class=\"d-flex justify-content-start\">\n            <div class=\"flex-shrink-1\">\n                <button (click)=\"toggleSidebar()\" class=\"navbar-toggler\" type=\"button\">\n                    <scrm-image class=\"responsive-menu-toggler\" image=\"hamburger\"></scrm-image>\n                </button>\n            </div>\n\n            <div class=\"d-flex flex-grow-1 justify-content-center\">\n                <scrm-search-bar\n                        #searchBarComponent\n                        [labelKey]=\"'LBL_FILTER_MODULES'\"\n                        [klass]=\"'search-bar-mobile-menu'\"\n                        [searchTrigger]=\"'input'\"\n                        (searchExpression)=\"search($event)\">\n                </scrm-search-bar>\n            </div>\n        </div>\n    </ng-template>\n    <ng-template pTemplate=\"content\">\n        <div class=\"sidebar-container\">\n            <ng-container *ngIf=\"displayedItems()\">\n                <scrm-mobile-menu [menuItems]=\"displayedItems\"></scrm-mobile-menu>\n            </ng-container>\n        </div>\n    </ng-template>\n</p-sidebar>\n" }]
    }], function () { return [{ type: AppStateStore }, { type: NavigationStore }, { type: ModuleNameMapper }, { type: ModuleNavigation }, { type: LanguageStore }]; }, { searchBarComponent: [{
            type: ViewChild,
            args: ['searchBarComponent']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function SortButtonComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "a", 1);
    i0.ɵɵlistener("click", function SortButtonComponent_ng_container_0_Template_a_click_1_listener() { const restoredCtx = i0.ɵɵrestoreView(_r3); const direction_r1 = restoredCtx.ngIf; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.changeSorting(direction_r1)); });
    i0.ɵɵelement(2, "scrm-image", 2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const direction_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("image", ctx_r0.getStatusIcon(direction_r1));
} }
class SortButtonComponent {
    constructor() {
        this.statusIcons = {
            NONE: 'sort',
            ASC: 'sort_ascend',
            DESC: 'sort_descend'
        };
        this.nextDirection = {
            NONE: SortDirection.DESC,
            ASC: SortDirection.NONE,
            DESC: SortDirection.ASC
        };
    }
    ngOnInit() {
        this.direction$ = this.state.getSortDirection();
    }
    getStatusIcon(direction) {
        return this.statusIcons[direction];
    }
    changeSorting(direction) {
        const newDirection = this.nextDirection[direction];
        this.state.changeSortDirection(newDirection);
    }
    static { this.ɵfac = function SortButtonComponent_Factory(t) { return new (t || SortButtonComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SortButtonComponent, selectors: [["scrm-sort-button"]], inputs: { state: "state" }, decls: 2, vars: 3, consts: [[4, "ngIf"], [1, "btn", "btn-sm", "p-0", "sort-button", 3, "click"], [1, "sort-icon", "sicon", 3, "image"]], template: function SortButtonComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SortButtonComponent_ng_container_0_Template, 3, 1, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.direction$));
        } }, dependencies: [i2.NgIf, ImageComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SortButtonComponent, [{
        type: Component,
        args: [{ selector: 'scrm-sort-button', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(direction$ | async) as direction\">\n    <a class=\"btn btn-sm p-0 sort-button\" (click)=\"changeSorting(direction)\">\n        <scrm-image class=\"sort-icon sicon\" [image]=\"getStatusIcon(direction)\"></scrm-image>\n    </a>\n</ng-container>\n\n" }]
    }], function () { return []; }, { state: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SortButtonModule {
    static { this.ɵfac = function SortButtonModule_Factory(t) { return new (t || SortButtonModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SortButtonModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SortButtonModule, [{
        type: NgModule,
        args: [{
                declarations: [SortButtonComponent],
                exports: [
                    SortButtonComponent
                ],
                imports: [
                    CommonModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SortButtonModule, { declarations: [SortButtonComponent], imports: [CommonModule,
        ImageModule], exports: [SortButtonComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FiltersListGQL extends ListGQL {
    constructor(apollo) {
        super(apollo);
        this.apollo = apollo;
    }
    /**
     * Fetch the list of filters from the backend
     *
     * @param {string} module to use
     * @param {object} criteria to use
     * @param {object} sort to use
     * @param {object} pagination to use
     * @returns {object} Observable<any>
     */
    get(module, criteria, sort, pagination) {
        return super.get(module, criteria, sort, pagination);
    }
    /**
     * Map record. Allow for extensions
     * @param record
     */
    mapRecord(record) {
        if (!record) {
            return record;
        }
        record.key = record.id || (record.attributes && record.attributes.id) || '';
        const contents = (record.attributes && record.attributes && record.attributes.contents) || null;
        if (contents) {
            const savedFilter = { ...record };
            savedFilter.criteria = contents;
            return savedFilter;
        }
        return record;
    }
    static { this.ɵfac = function FiltersListGQL_Factory(t) { return new (t || FiltersListGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FiltersListGQL, factory: FiltersListGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FiltersListGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FilterListStore extends RecordListStore {
    /**
     * Constructor
     * @param listGQL
     * @param configs
     * @param preferences
     * @param language
     * @param message
     * @param auth
     * @param moduleNameMapper
     * @param localStorageService
     */
    constructor(listGQL, configs, preferences, language, message, auth, moduleNameMapper, localStorageService) {
        super(listGQL, configs, preferences, language, message, localStorageService);
        this.listGQL = listGQL;
        this.configs = configs;
        this.preferences = preferences;
        this.language = language;
        this.message = message;
        this.auth = auth;
        this.moduleNameMapper = moduleNameMapper;
        this.localStorageService = localStorageService;
        this.moduleName = 'saved-search';
        this.filterFields = {
            module: 'search_module',
            user: 'assigned_user_id',
        };
    }
    /**
     * Initialize store
     * @param module
     */
    init(module) {
        const result$ = super.init(this.moduleName, false);
        this.initCriteria(module);
        return result$;
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordList>
     */
    load(useCache = true) {
        return super.load(useCache);
    }
    /**
     * Get current list of saved filters
     */
    getFilters() {
        return this.records;
    }
    /**
     * Add new filter to list
     * @param filter
     */
    addFilter(filter) {
        let isNew = true;
        const filters = this.records;
        const newList = [];
        filters.forEach(record => {
            if (record.id === filter.id) {
                newList.push(filter);
                isNew = false;
                return;
            }
            newList.push(record);
        });
        if (isNew) {
            newList.push(filter);
        }
        this.updateState({
            ...this.internalState,
            records: newList,
        });
    }
    /**
     * Remove existing filter
     * @param filter
     */
    removeFilter(filter) {
        if (!filter || !filter.id) {
            return;
        }
        const filters = this.records;
        const newList = [];
        filters.forEach(record => {
            if (record.id === filter.id) {
                return;
            }
            newList.push(record);
        });
        this.updateState({
            ...this.internalState,
            records: newList,
        });
    }
    /**
     * Initialize criteria
     * @param module
     */
    initCriteria(module) {
        const criteria = this.criteria;
        criteria.filters[this.filterFields.module] = {
            field: this.filterFields.module,
            operator: '=',
            values: [this.moduleNameMapper.toLegacy(module)]
        };
        criteria.filters[this.filterFields.user] = {
            field: this.filterFields.user,
            operator: '=',
            values: [this.auth.getCurrentUser().id]
        };
        this.updateSearchCriteria(criteria, false);
    }
    static { this.ɵfac = function FilterListStore_Factory(t) { return new (t || FilterListStore)(i0.ɵɵinject(FiltersListGQL), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(AuthService), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterListStore, factory: FilterListStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterListStore, [{
        type: Injectable
    }], function () { return [{ type: FiltersListGQL }, { type: SystemConfigStore }, { type: UserPreferenceStore }, { type: LanguageStore }, { type: MessageService }, { type: AuthService }, { type: ModuleNameMapper }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FilterListStoreFactory {
    /**
     * Constructor
     * @param listGQL
     * @param configs
     * @param preferences
     * @param language
     * @param message
     * @param auth
     * @param moduleNameMapper
     * @param localStorageService
     */
    constructor(listGQL, configs, preferences, language, message, auth, moduleNameMapper, localStorageService) {
        this.listGQL = listGQL;
        this.configs = configs;
        this.preferences = preferences;
        this.language = language;
        this.message = message;
        this.auth = auth;
        this.moduleNameMapper = moduleNameMapper;
        this.localStorageService = localStorageService;
    }
    /**
     * Create a new FilterListStore instance
     * @returns {object} FilterListStore
     */
    create() {
        return new FilterListStore(this.listGQL, this.configs, this.preferences, this.language, this.message, this.auth, this.moduleNameMapper, this.localStorageService);
    }
    static { this.ɵfac = function FilterListStoreFactory_Factory(t) { return new (t || FilterListStoreFactory)(i0.ɵɵinject(FiltersListGQL), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(AuthService), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterListStoreFactory, factory: FilterListStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterListStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: FiltersListGQL }, { type: SystemConfigStore }, { type: UserPreferenceStore }, { type: LanguageStore }, { type: MessageService }, { type: AuthService }, { type: ModuleNameMapper }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelStore {
    constructor(listStoreFactory, languageStore, statisticsStoreFactory, filterListStoreFactory, meta, preferences) {
        this.listStoreFactory = listStoreFactory;
        this.languageStore = languageStore;
        this.statisticsStoreFactory = statisticsStoreFactory;
        this.filterListStoreFactory = filterListStoreFactory;
        this.meta = meta;
        this.preferences = preferences;
        this.show = false;
        this.showFilter = false;
        this.filterApplied = false;
        this.preferenceKey = null;
        this.subs = [];
        this.recordList = listStoreFactory.create();
        this.filterList = this.filterListStoreFactory.create();
        this.criteria$ = this.recordList.criteria$;
        this.statistics = {};
        this.metadataState = new BehaviorSubject({});
        this.metadata$ = this.metadataState.asObservable();
        this.loading$ = this.recordList.loading$;
    }
    getTitle() {
        let label = this.languageStore.getFieldLabel(this.metadata.title_key, this.parentModule);
        if (!label) {
            const moduleList = this.languageStore.getAppListString('moduleList');
            label = (moduleList && moduleList[this.metadata.title_key]) || '';
        }
        return label;
    }
    getIcon() {
        return this.metadata.icon;
    }
    clear() {
        this.metadataState.unsubscribe();
        this.metadataState = null;
        this.recordList.clear();
        this.recordList = null;
        this.subs.forEach(sub => sub.unsubscribe());
    }
    clearAuthBased() {
        this.recordList.clearAuthBased();
    }
    searchFilter() {
        this.filterApplied = true;
        this.showFilter = false;
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} parentModule name
     * @param {string} parentId id
     * @param {object} meta to use
     * @param {object} parentRecord$ to use
     */
    init(parentModule, parentId, meta, parentRecord$ = null) {
        this.parentModule = parentModule;
        this.parentId = parentId;
        this.metadata = meta;
        this.metadataState.next(this.metadata);
        const meta$ = this.meta.getMetadata(meta.module).pipe(tap(() => {
            this.recordList.load().pipe(take(1)).subscribe();
        }));
        this.searchMetadata$ = meta$.pipe(map(meta => meta.search));
        const filter = this.initSearchCriteria(this.parentModule, this.parentId, meta);
        this.recordList.init(meta.module, false, 'list_max_entries_per_subpanel', filter);
        this.initStatistics(meta, parentModule, parentId);
        if (parentRecord$) {
            this.parentRecord$ = parentRecord$;
            this.parentRecord$.subscribe(record => this.parentRecord = record);
        }
    }
    setFilters(filters, reload = true) {
        this.recordList.setFilters(filters, reload, null);
    }
    isAnyFilterApplied() {
        return this.hasActiveFilter() || !this.areAllCurrentCriteriaFilterEmpty();
    }
    hasActiveFilter() {
        const activeFilters = this.recordList.criteria;
        if (activeFilters) {
            return false;
        }
        const filterKeys = Object.keys(activeFilters) ?? [];
        if (!filterKeys || !filterKeys.length) {
            return false;
        }
        if (filterKeys.length > 1) {
            return true;
        }
        const currentFilter = activeFilters[filterKeys[0]];
        return currentFilter.key && currentFilter.key !== '' && currentFilter.key !== 'default';
    }
    areAllCurrentCriteriaFilterEmpty() {
        return Object.keys(this.getFilters() ?? {}).every(key => this.getFilters()[key].operator === '');
    }
    getFilters() {
        return this.recordList?.criteria?.filters ?? {};
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordList>
     */
    load(useCache = true) {
        return this.recordList.load(useCache);
    }
    /**
     * Get statistic store
     *
     * @param {string} key key of statistic
     * @returns {object} SingleValueStatisticsStore
     */
    getStatistic(key) {
        if (!this.statistics[key]) {
            return null;
        }
        return this.statistics[key];
    }
    resetFilters(reload = true) {
        this.recordList.resetFilters(reload);
    }
    clearFilter() {
        this.resetFilters();
        this.filterApplied = false;
        this.showFilter = false;
    }
    /**
     * add search criteria
     *
     * @param {string} parentModule name
     * @param {string} parentId id
     * @param {string} subpanel name
     */
    initSearchCriteria(parentModule, parentId, meta) {
        const sortOrder = meta?.sort_order ?? 'desc';
        const orderBy = meta?.sort_by ?? '';
        return {
            key: 'default',
            module: 'saved-search',
            attributes: { contents: '' },
            criteria: {
                name: 'default',
                filters: {},
                preset: {
                    type: 'subpanel',
                    params: {
                        subpanel: meta?.name,
                        parentModule,
                        parentId
                    }
                },
                sortOrder,
                orderBy
            },
        };
    }
    /**
     * Load / reload statistics
     *
     * @param {string} key of statistic
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<Statistic>
     */
    loadStatistics(key, useCache = true) {
        if (!this.statistics[key]) {
            return null;
        }
        return this.statistics[key].load(useCache);
    }
    /**
     * Load / reload all statistics
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<Statistic>
     */
    loadAllStatistics(useCache = true) {
        if (!this.statistics || !Object.keys(this.statistics).length) {
            return null;
        }
        const stats$ = [];
        Object.keys(this.statistics).forEach(statisticKey => {
            if (!this.statistics[statisticKey]) {
                return;
            }
            stats$.push(this.loadStatistics(statisticKey, useCache));
        });
        return forkJoin(stats$);
    }
    /**
     * Should batch statistic
     *
     * @returns {boolean} shouldBatch
     */
    shouldBatchStatistic() {
        const metadata = this.metadata || {};
        return !(metadata.insightWidget && metadata.insightWidget.batch && metadata.insightWidget.batch === false);
    }
    /**
     * Set loading
     *
     * @param {string} key of statistic
     * @param {boolean} loading bool
     */
    setStatisticsLoading(key, loading) {
        if (!this.statistics[key]) {
            return;
        }
        this.statistics[key].setLoading(loading);
    }
    /**
     * Set all statistics loading
     *
     * @param {boolean} loading bool
     */
    setAllStatisticsLoading(loading) {
        if (!this.statistics || !Object.keys(this.statistics).length) {
            return;
        }
        Object.keys(this.statistics).forEach(statisticKey => {
            if (!this.statistics[statisticKey]) {
                return;
            }
            this.setStatisticsLoading(statisticKey, loading);
        });
    }
    /**
     * Set Statistic value
     *
     * @param {string} key of statistic
     * @param {object} statistic Statistic
     * @param {boolean} cache bool
     */
    setStatistics(key, statistic, cache = false) {
        if (!this.statistics[key]) {
            return;
        }
        this.statistics[key].setStatistic(key, statistic, cache);
    }
    /**
     * Get statistic query
     *
     * @param {string} key of statistic
     * @returns {object} StatisticsQuery
     */
    getStatisticQuery(key) {
        return this.statistics[key].getQuery();
    }
    /**
     * Get all statistics queries
     *
     * @returns {object} StatisticsQuery
     */
    getAllStatisticQuery() {
        if (!this.statistics || !Object.keys(this.statistics).length) {
            return {};
        }
        const queriesMap = {};
        Object.keys(this.statistics).forEach(statisticKey => {
            if (!this.statistics[statisticKey]) {
                return;
            }
            queriesMap[statisticKey] = this.getStatisticQuery(statisticKey);
        });
        return queriesMap;
    }
    /**
     * Get widget layout
     *
     * @returns {any} any
     */
    getWidgetLayout() {
        const meta = this.metadata;
        if (!meta || !meta.insightWidget || !meta.insightWidget.options || !meta.insightWidget.options.insightWidget) {
            return { rows: [] };
        }
        const layout = deepClone(meta.insightWidget.options.insightWidget);
        if (!layout.rows || !layout.rows.length) {
            layout.rows = {};
        }
        return layout;
    }
    toggleFilter() {
        return this.showFilter = !this.showFilter;
    }
    /**
     * Init statistics store
     *
     * @param {object} meta for subpanel
     * @param {string} parentModule name
     * @param {string} parentId {id}
     */
    initStatistics(meta, parentModule, parentId) {
        const layout = this.getWidgetLayout();
        layout.rows.forEach(row => {
            if (!row.cols || !row.cols.length) {
                return;
            }
            row.cols.forEach(col => {
                if (!col.statistic || typeof col.statistic !== 'string') {
                    return;
                }
                this.initStatistic(col.statistic, meta, parentModule, parentId);
                col.store = this.statistics[col.statistic];
            });
        });
    }
    /**
     * Init a single value statistic
     *
     * @param {string} statisticKey to use
     * @param {object} meta SubPanelDefinition
     * @param {string} parentModule to use
     * @param {string} parentId to use
     */
    initStatistic(statisticKey, meta, parentModule, parentId) {
        this.statistics[statisticKey] = this.statisticsStoreFactory.create();
        this.statistics[statisticKey].init(meta.module, {
            key: statisticKey,
            context: { module: parentModule, id: parentId },
            params: { subpanel: meta.name }
        }, false);
    }
    static { this.ɵfac = function SubpanelStore_Factory(t) { return new (t || SubpanelStore)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SingleValueStatisticsStoreFactory), i0.ɵɵinject(FilterListStoreFactory), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelStore, factory: SubpanelStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelStore, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }, { type: LanguageStore }, { type: SingleValueStatisticsStoreFactory }, { type: FilterListStoreFactory }, { type: MetadataStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelStoreFactory {
    constructor(listStoreFactory, languageStore, statisticsStoreFactory, filterListStoreFactory, meta, preferences) {
        this.listStoreFactory = listStoreFactory;
        this.languageStore = languageStore;
        this.statisticsStoreFactory = statisticsStoreFactory;
        this.filterListStoreFactory = filterListStoreFactory;
        this.meta = meta;
        this.preferences = preferences;
    }
    create() {
        return new SubpanelStore(this.listStoreFactory, this.languageStore, this.statisticsStoreFactory, this.filterListStoreFactory, this.meta, this.preferences);
    }
    static { this.ɵfac = function SubpanelStoreFactory_Factory(t) { return new (t || SubpanelStoreFactory)(i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SingleValueStatisticsStoreFactory), i0.ɵɵinject(FilterListStoreFactory), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelStoreFactory, factory: SubpanelStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordListStoreFactory }, { type: LanguageStore }, { type: SingleValueStatisticsStoreFactory }, { type: FilterListStoreFactory }, { type: MetadataStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ViewStore {
    constructor(appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore) {
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.moduleNavigation = moduleNavigation;
        this.metadataStore = metadataStore;
        this.appState$ = this.appStateStore.vm$;
        this.language$ = this.languageStore.vm$;
        this.navigation$ = this.navigationStore.vm$;
        this.module$ = this.appState$.pipe(combineLatestWith(this.navigation$), map(([appStateInfo, navigationInfo]) => this.moduleNavigation.getModuleInfo(appStateInfo.module, navigationInfo)));
        this.appData$ = this.appState$.pipe(combineLatestWith(this.module$, this.language$, this.navigation$), map(([appState, module, language, navigation]) => {
            this.appData = { appState, module, language, navigation };
            return this.appData;
        }));
        this.metadata$ = metadataStore.metadata$.pipe(tap(metadata => { this.metadata = metadata; }));
    }
    clear() {
    }
    clearAuthBased() {
        this.clear();
    }
    get appState() {
        if (!this.appData.appState) {
            return {};
        }
        return this.appData.appState;
    }
    get module() {
        return this.appData.module;
    }
    get language() {
        if (!this.appData.language) {
            return {
                appStrings: {},
                appListStrings: {},
                modStrings: {},
                languageKey: ''
            };
        }
        return this.appData.language;
    }
    get appStrings() {
        return this.language.appStrings;
    }
    get appListStrings() {
        return this.language.appListStrings;
    }
    get modStrings() {
        return this.language.modStrings;
    }
    get navigation() {
        return this.appData.navigation;
    }
    get searchMeta() {
        if (!this.metadata.search) {
            return {
                layout: {
                    basic: {},
                    advanced: {}
                }
            };
        }
        return this.metadata.search;
    }
    static { this.ɵfac = function ViewStore_Factory(t) { return new (t || ViewStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ViewStore, factory: ViewStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ViewStore, [{
        type: Injectable
    }], function () { return [{ type: AppStateStore }, { type: LanguageStore }, { type: NavigationStore }, { type: ModuleNavigation }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsBatch {
    constructor(fetchGQL) {
        this.fetchGQL = fetchGQL;
    }
    /**
     * Get statistics
     *
     * @param {string} module to use
     * @param {object} queries StatisticsQueryMap
     * @returns {object} Observable<any>
     */
    fetch(module, queries) {
        return this.fetchGQL.fetch(module, queries);
    }
    static { this.ɵfac = function StatisticsBatch_Factory(t) { return new (t || StatisticsBatch)(i0.ɵɵinject(StatisticsFetchGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StatisticsBatch, factory: StatisticsBatch.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsBatch, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: StatisticsFetchGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordConvertService {
    constructor(systemConfigStore) {
        this.systemConfigStore = systemConfigStore;
    }
    duplicateOnModule(prevRecord, newRecord, vardefs, moduleMetadata) {
        const excludedFields = this.systemConfigStore.getConfigValue('convert_ignore') ?? [];
        const nextModule = newRecord.module ?? '';
        newRecord.id = '';
        newRecord.attributes.id = '';
        Object.keys(vardefs).forEach((fieldName) => {
            if (isVoid(prevRecord?.attributes[fieldName]) || excludedFields?.default.includes(fieldName)) {
                return;
            }
            if (Object.keys(excludedFields).includes(nextModule) && excludedFields[nextModule].includes(fieldName)) {
                return;
            }
            if (moduleMetadata.recordView?.vardefs[fieldName].type != vardefs[fieldName].type) {
                return;
            }
            newRecord.attributes[fieldName] = prevRecord.attributes[fieldName];
        });
        return newRecord;
    }
    getViewFieldsObservable(meta) {
        return of(meta.recordView).pipe(map((recordMetadata) => {
            const fieldsMap = {};
            recordMetadata.panels.forEach(panel => {
                panel.rows.forEach(row => {
                    row.cols.forEach(col => {
                        const fieldName = col.name ?? col.fieldDefinition.name ?? '';
                        fieldsMap[fieldName] = col;
                    });
                });
            });
            Object.keys(recordMetadata.vardefs).forEach(fieldKey => {
                const vardef = recordMetadata.vardefs[fieldKey] ?? null;
                if (!vardef || isEmpty(vardef)) {
                    return;
                }
                // already defined. skip
                if (fieldsMap[fieldKey]) {
                    return;
                }
                if (vardef.type == 'relate') {
                    return;
                }
                fieldsMap[fieldKey] = {
                    name: fieldKey,
                    vardefBased: true,
                    label: vardef.vname ?? '',
                    type: vardef.type ?? '',
                    display: vardef.display ?? '',
                    fieldDefinition: vardef,
                    metadata: vardef.metadata ?? {},
                    logic: vardef.logic ?? {}
                };
            });
            return Object.values(fieldsMap);
        }));
    }
    static { this.ɵfac = function RecordConvertService_Factory(t) { return new (t || RecordConvertService)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordConvertService, factory: RecordConvertService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordConvertService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldActionHandler extends ActionHandler {
    shouldDisplay(data) {
        return true;
    }
    ;
    checkRecordAccess(data, defaultAcls = []) {
        const record = data.store.recordStore.getBaseRecord();
        const acls = record.acls ?? [];
        if (!acls || !acls.length) {
            return false;
        }
        const action = data.action ?? null;
        return this.checkAccess(action, acls, defaultAcls);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldClearAction extends FieldActionHandler {
    constructor() {
        super();
        this.key = 'clear';
        this.modes = ['edit'];
    }
    run(data) {
        let staging = data.store.recordStore.getStaging();
        const field = staging.fields[data.action.fieldName];
        field.formControl.setValue('');
    }
    static { this.ɵfac = function FieldClearAction_Factory(t) { return new (t || FieldClearAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldClearAction, factory: FieldClearAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldClearAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldCopyAction extends FieldActionHandler {
    constructor(clipboard) {
        super();
        this.clipboard = clipboard;
        this.key = 'copy';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
        let staging = data.store.recordStore.getStaging();
        const field = staging.fields[data.action.fieldName];
        this.clipboard.copy(field.value);
    }
    static { this.ɵfac = function FieldCopyAction_Factory(t) { return new (t || FieldCopyAction)(i0.ɵɵinject(i1$4.Clipboard)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldCopyAction, factory: FieldCopyAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldCopyAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$4.Clipboard }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CalculateValueBackendAction extends FieldActionHandler {
    constructor(asyncActionService, processService, messages, recordMappers, baseMapper, activeFieldsChecker) {
        super();
        this.asyncActionService = asyncActionService;
        this.processService = processService;
        this.messages = messages;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'calculateValueBackend';
        this.modes = ['edit', 'create'];
        recordMappers.register('default', baseMapper.getKey(), baseMapper);
    }
    run(data) {
        let record = data.store.recordStore.getStaging();
        const field = record.fields[data.action.fieldName];
        const action = data.action;
        if (!record || !field) {
            return;
        }
        const activeOnFields = (action.params && action.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (action.params && action.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        const process = action.params && action.params.process;
        if (!process) {
            return;
        }
        const isActive = this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
        if (isActive) {
            const processType = process;
            const baseRecord = this.getBaseRecord(record);
            const options = {
                action: processType,
                module: record.module ?? '',
                record: baseRecord
            };
            field.loading = true;
            this.processService.submit(processType, options).pipe(take(1)).subscribe((result) => {
                const value = result?.data?.value ?? null;
                field.loading = false;
                if (value === null) {
                    this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
                    return;
                }
                this.updateValue(field, value.toString(), record);
            }, (error) => {
                field.loading = false;
                this.messages.addDangerMessageByKey("ERR_FIELD_LOGIC_BACKEND_CALCULATION");
            });
        }
    }
    getBaseRecord(record) {
        if (!record) {
            return null;
        }
        this.mapRecordFields(record);
        const baseRecord = {
            id: record.id,
            type: record.type,
            module: record.module,
            attributes: record.attributes,
            acls: record.acls
        };
        return deepClone(baseRecord);
    }
    /**
     * Map staging fields
     */
    mapRecordFields(record) {
        const mappers = this.recordMappers.get(record.module);
        Object.keys(mappers).forEach(key => {
            const mapper = mappers[key];
            mapper.map(record);
        });
    }
    /**
     * Update the new value
     * @param {object} field
     * @param {string} value
     * @param {object} record
     */
    updateValue(field, value, record) {
        field.value = value.toString();
        field.formControl.setValue(value);
        // re-validate the parent form-control after value update
        record.formGroup.updateValueAndValidity({ onlySelf: true, emitEvent: true });
    }
    static { this.ɵfac = function CalculateValueBackendAction_Factory(t) { return new (t || CalculateValueBackendAction)(i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(ProcessService), i0.ɵɵinject(MessageService), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper), i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CalculateValueBackendAction, factory: CalculateValueBackendAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CalculateValueBackendAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: AsyncActionService }, { type: ProcessService }, { type: MessageService }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }, { type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldActionManager extends BaseActionManager {
    constructor(calculate, clear, copy) {
        super();
        this.calculate = calculate;
        this.clear = clear;
        this.copy = copy;
        calculate.modes.forEach(mode => this.actions[mode][calculate.key] = calculate);
        clear.modes.forEach(mode => this.actions[mode][clear.key] = clear);
        copy.modes.forEach(mode => this.actions[mode][copy.key] = copy);
    }
    static { this.ɵfac = function FieldActionManager_Factory(t) { return new (t || FieldActionManager)(i0.ɵɵinject(CalculateValueBackendAction), i0.ɵɵinject(FieldClearAction), i0.ɵɵinject(FieldCopyAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldActionManager, factory: FieldActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: CalculateValueBackendAction }, { type: FieldClearAction }, { type: FieldCopyAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldActionsAdapter extends BaseActionsAdapter {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `record-${action.key}`;
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        return {
            action: actionName,
            module: moduleName,
            id: (context && context.record && context.record.id) || '',
            params: (action && action.params) || [],
        };
    }
    static { this.ɵfac = function BaseFieldActionsAdapter_Factory(t) { i0.ɵɵinvalidFactory(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseFieldActionsAdapter, factory: BaseFieldActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFieldActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: undefined }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldActionsAdapter extends BaseFieldActionsAdapter {
    constructor(store, metadata, appMetadataStore, language, actionManager, asyncActionService, message, confirmation, selectModalService, viewName, fieldName) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.viewName = viewName;
        this.fieldName = fieldName;
    }
    getActions(context) {
        return combineLatest([
            this.metadata.fieldActions$,
            this.store.mode$,
            this.store.record$,
            this.store.language$
        ]).pipe(map(([meta, mode]) => {
            if (!mode || !meta) {
                return [];
            }
            const actionsMeta = meta[this.viewName][this.fieldName] ?? [];
            return this.parseModeActions(actionsMeta, mode, this.store.getViewContext());
        }));
    }
    buildActionData(action, context) {
        return {
            store: this.store,
            action: action
        };
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const baseRecord = this.store.recordStore.getBaseStaging();
        this.message.removeMessages();
        return {
            action: actionName,
            module: baseRecord.module,
            id: baseRecord.id,
            params: (action && action.params) || [],
            record: baseRecord
        };
    }
    getMode() {
        return this.store.getMode();
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, context) {
        this.store.load(false).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function FieldActionsAdapter_Factory(t) { i0.ɵɵinvalidFactory(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldActionsAdapter, factory: FieldActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }, { type: AppMetadataStore }, { type: LanguageStore }, { type: FieldActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: undefined }, { type: undefined }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FieldActionsAdapterFactory {
    constructor(metadata, appMetadataStore, language, actionManager, asyncActionService, message, confirmation, selectModalService) {
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
    }
    create(viewName, fieldName, store) {
        const adapter = new FieldActionsAdapter(store, this.metadata, this.appMetadataStore, this.language, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.selectModalService, viewName, fieldName);
        return adapter;
    }
    static { this.ɵfac = function FieldActionsAdapterFactory_Factory(t) { return new (t || FieldActionsAdapterFactory)(i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(FieldActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FieldActionsAdapterFactory, factory: FieldActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: MetadataStore }, { type: AppMetadataStore }, { type: LanguageStore }, { type: FieldActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$7 = {
    module: "",
    recordID: "",
    loading: false,
    widgets: false,
    showSidebarWidgets: false,
    showTopWidget: false,
    showSubpanels: false,
    mode: "detail",
    params: {
        returnModule: "",
        returnId: "",
        returnAction: "",
    },
};
class RecordViewStore extends ViewStore {
    constructor(recordFetchGQL, recordSaveGQL, appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore, localStorage, message, subpanelFactory, recordManager, statisticsBatch, recordStoreFactory, preferences, panelLogicManager, recordConvertService) {
        super(appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore);
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.moduleNavigation = moduleNavigation;
        this.metadataStore = metadataStore;
        this.localStorage = localStorage;
        this.message = message;
        this.subpanelFactory = subpanelFactory;
        this.recordManager = recordManager;
        this.statisticsBatch = statisticsBatch;
        this.recordStoreFactory = recordStoreFactory;
        this.preferences = preferences;
        this.panelLogicManager = panelLogicManager;
        this.recordConvertService = recordConvertService;
        this.panels = [];
        /** Internal Properties */
        this.cache$ = null;
        this.internalState = deepClone(initialState$7);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subpanelReloadSubject = new BehaviorSubject({});
        this.subpanelReloadSub = [];
        this.subs = [];
        this.fieldSubs = [];
        this.panelsSubject = new BehaviorSubject(this.panels);
        this.viewModeSubject = new BehaviorSubject("detail");
        this.viewMode$ = this.viewModeSubject.asObservable();
        this.actionAdaptorFactory = inject(FieldActionsAdapterFactory);
        this.panels$ = this.panelsSubject.asObservable();
        this.recordStore = recordStoreFactory.create(this.getViewFieldsObservable(), this.getRecordMetadata$());
        this.record$ = this.recordStore.state$.pipe(distinctUntilChanged());
        this.stagingRecord$ = this.recordStore.staging$.pipe(distinctUntilChanged());
        this.loading$ = this.state$.pipe(map((state) => state.loading));
        this.widgets$ = this.state$.pipe(map((state) => state.widgets));
        this.showSidebarWidgets$ = this.state$.pipe(map((state) => state.showSidebarWidgets));
        this.showTopWidget$ = this.state$.pipe(map((state) => state.showTopWidget));
        this.showSubpanels$ = this.state$.pipe(map((state) => state.showSubpanels));
        this.mode$ = this.state$.pipe(map((state) => state.mode));
        this.subpanelReload$ = this.subpanelReloadSubject.asObservable();
        const data$ = this.record$.pipe(combineLatestWith(this.loading$), map(([record, loading]) => {
            this.data = { record, loading };
            return this.data;
        }));
        this.vm$ = data$.pipe(combineLatestWith(this.appData$, this.metadata$), map(([data, appData, metadata]) => {
            this.vm = { data, appData, metadata };
            return this.vm;
        }));
        this.subpanelsState = new BehaviorSubject({});
        this.subpanels$ = this.subpanelsState.asObservable();
        this.viewContext$ = this.record$.pipe(map(() => this.getViewContext()));
        this.initPanels();
        this.recordValidationHandler = inject(RecordValidationHandler);
    }
    get widgets() {
        return this.internalState.widgets;
    }
    set widgets(show) {
        this.updateState({
            ...this.internalState,
            widgets: show,
        });
    }
    get showSidebarWidgets() {
        return this.internalState.showSidebarWidgets;
    }
    set showSidebarWidgets(show) {
        this.savePreference(this.getModuleName(), "show-sidebar-widgets", show);
        this.updateState({
            ...this.internalState,
            showSidebarWidgets: show,
        });
    }
    get showTopWidget() {
        return this.internalState.showTopWidget;
    }
    set showTopWidget(show) {
        this.updateState({
            ...this.internalState,
            showTopWidget: show,
        });
    }
    get showSubpanels() {
        return this.internalState.showTopWidget;
    }
    set showSubpanels(show) {
        this.updateState({
            ...this.internalState,
            showSubpanels: show,
        });
    }
    get params() {
        return this.internalState.params || {};
    }
    set params(params) {
        this.updateState({
            ...this.internalState,
            params,
        });
    }
    getModuleName() {
        return this.internalState.module;
    }
    getRecordId() {
        return this.internalState.recordID;
    }
    getViewContext() {
        return {
            module: this.getModuleName(),
            id: this.getRecordId(),
            record: this.getBaseRecord(),
        };
    }
    getSubpanels() {
        return this.subpanels;
    }
    /**
     * Clean destroy
     */
    destroy() {
        this.clear();
    }
    /**
     * Initial record load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {string} recordID to use
     * @param {string} mode to use
     * @param {object} params to set
     * @returns {object} Observable<any>
     */
    init(module, recordID, mode = "detail", params = {}) {
        this.internalState.module = module;
        this.internalState.recordID = recordID;
        this.setMode(mode);
        this.initSubpanels(module, recordID);
        this.calculateShowWidgets();
        return this.load().pipe(tap(() => {
            this.showTopWidget = true;
            this.loadSubpanelStatistics(module);
            this.parseParams(params);
        }));
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.cache$ = null;
        this.clearSubpanels();
        this.subpanelsState.unsubscribe();
        this.updateState(deepClone(initialState$7));
        this.subs = this.safeUnsubscription(this.subs);
        this.fieldSubs = this.safeUnsubscription(this.fieldSubs);
    }
    /**
     * Get staging record
     *
     * @returns {string} ViewMode
     */
    getBaseRecord() {
        if (!this.internalState) {
            return null;
        }
        return this.recordStore.getBaseRecord();
    }
    /**
     * Get current view mode
     *
     * @returns {string} ViewMode
     */
    getMode() {
        if (!this.internalState) {
            return null;
        }
        return this.internalState.mode;
    }
    /**
     * Set new mode
     *
     * @param {string} mode ViewMode
     */
    setMode(mode) {
        this.updateState({ ...this.internalState, mode });
    }
    save() {
        this.appStateStore.updateLoading(`${this.internalState.module}-record-save`, true);
        this.updateState({
            ...this.internalState,
            loading: true,
        });
        return this.recordStore.save().pipe(catchError(() => {
            this.message.addDangerMessageByKey("LBL_ERROR_SAVING");
            return of({});
        }), finalize(() => {
            this.setMode("detail");
            this.appStateStore.updateLoading(`${this.internalState.module}-record-save`, false);
            this.updateState({
                ...this.internalState,
                loading: false,
            });
        }));
    }
    saveOnEdit() {
        return this.recordStore.save().pipe(catchError(() => {
            this.message.addDangerMessageByKey("LBL_ERROR_SAVING");
            return of({});
        }), finalize(() => {
            this.appStateStore.updateLoading(`${this.internalState.module}-record-save`, false);
            this.updateState({
                ...this.internalState,
                loading: false,
            });
        }));
    }
    /**
     * Load / reload record using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordViewState>
     */
    load(useCache = true) {
        this.updateState({
            ...this.internalState,
            loading: true,
        });
        return this.recordStore
            .retrieveRecord(this.internalState.module, this.internalState.recordID, useCache)
            .pipe(tap((data) => {
            this.updateState({
                ...this.internalState,
                recordID: data.id,
                module: data.module,
                loading: false,
            });
        }));
    }
    /**
     * Get summary template
     *
     * @returns {string} summary template label
     */
    getSummaryTemplate() {
        const metadata = this.metadata || {};
        const recordMeta = metadata.recordView || {};
        const templates = recordMeta.summaryTemplates || {};
        return templates[this.getMode()] || "";
    }
    /**
     * Parse query params
     *
     * @param {object} params to set
     */
    parseParams(params = {}) {
        if (!params) {
            return;
        }
        const currentParams = { ...this.internalState.params };
        Object.keys(params).forEach((paramKey) => {
            if (!isVoid(currentParams[paramKey])) {
                currentParams[paramKey] = params[paramKey];
                return;
            }
        });
        this.params = params;
    }
    /**
     * Load all statistics
     *
     * @param {string} module if to use cache
     */
    loadSubpanelStatistics(module) {
        const subpanels = this.subpanelsState.value;
        if (!subpanels) {
            return;
        }
        const queries = {};
        Object.keys(subpanels).forEach((subpanelKey) => {
            const subpanel = subpanels[subpanelKey];
            const statsMap = subpanel.statistics;
            if (!statsMap || !Object.keys(statsMap).length) {
                return;
            }
            if (subpanel.shouldBatchStatistic() === false) {
                subpanel.loadAllStatistics().pipe(take(1)).subscribe();
                return;
            }
            const subpanelQueries = subpanel.getAllStatisticQuery();
            Object.keys(subpanelQueries).forEach((subpanelQueryKey) => {
                const queryKey = this.buildStatKey(subpanelKey, subpanelQueryKey);
                queries[queryKey] = subpanelQueries[subpanelQueryKey];
            });
            subpanel.setAllStatisticsLoading(true);
        });
        this.statisticsBatch
            .fetch(module, queries)
            .pipe(take(1))
            .subscribe((stats) => {
            Object.keys(subpanels).forEach((subpanelKey) => {
                const subpanel = subpanels[subpanelKey];
                const subpanelQueries = subpanel.getAllStatisticQuery();
                Object.keys(subpanelQueries).forEach((subpanelQueryKey) => {
                    const queryKey = this.buildStatKey(subpanelKey, subpanelQueryKey);
                    const stat = stats[queryKey];
                    if (!stat) {
                        return;
                    }
                    subpanel.setStatistics(subpanelQueryKey, stat, true);
                });
                subpanel.setAllStatisticsLoading(false);
            });
        });
    }
    buildStatKey(subpanelKey, subpanelQueryKey) {
        subpanelKey = subpanelKey.replace(/_/g, "-");
        subpanelQueryKey = subpanelQueryKey.replace(/_/g, "-");
        return subpanelKey + "-" + subpanelQueryKey;
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        const previousMode = this.internalState?.mode;
        this.internalState = state;
        this.store.next(state);
        if (state.mode && state.mode !== previousMode) {
            console.log("[record-view.store.ts] Mode changed:", state.mode);
            this.viewModeSubject.next(state.mode); // ✅ emit new mode
        }
    }
    /**
     * Init subpanels
     *
     * @param {string} module parent module
     * @param {string} recordId id
     */
    initSubpanels(module, recordId) {
        this.showSubpanels = true;
        this.metadataStore.subPanelMetadata$.subscribe((meta) => {
            this.clearSubpanels();
            Object.keys(meta).forEach((key) => {
                this.subpanels[key] = this.subpanelFactory.create();
                this.subpanels[key].init(module, recordId, meta[key], this.record$);
            });
            this.subpanelsState.next(this.subpanels);
            Object.keys(this.subpanels).forEach((subpanelKey) => {
                const subpanel = this.subpanels[subpanelKey];
                this.subpanelReloadSub.push(subpanel.recordList.records$
                    .pipe(tap(() => {
                    const update = {};
                    update[subpanelKey] = true;
                    this.subpanelReloadSubject.next(update);
                }))
                    .subscribe());
            });
        });
    }
    initPanels() {
        const panelSub = combineLatest([
            this.metadataStore.recordViewMetadata$,
            this.stagingRecord$,
            this.languageStore.vm$,
        ]).subscribe(([meta, record, languages]) => {
            const panels = [];
            const module = (record && record.module) || "";
            this.safeUnsubscription(this.fieldSubs);
            meta.panels.forEach((panelDefinition) => {
                const label = panelDefinition.label
                    ? panelDefinition.label.toUpperCase()
                    : this.languageStore.getFieldLabel(panelDefinition.key.toUpperCase(), module, languages);
                const panel = { label, key: panelDefinition.key, rows: [] };
                let adaptor = null;
                const tabDef = meta.templateMeta.tabDefs[panelDefinition.key.toUpperCase()] ?? null;
                if (tabDef) {
                    panel.meta = tabDef;
                }
                panelDefinition.rows.forEach((rowDefinition) => {
                    const row = { cols: [] };
                    rowDefinition.cols.forEach((cellDefinition) => {
                        const cellDef = { ...cellDefinition };
                        const fieldActions = cellDefinition.fieldActions || null;
                        if (fieldActions) {
                            adaptor = this.actionAdaptorFactory.create("recordView", cellDef.name, this);
                            cellDef.adaptor = adaptor;
                        }
                        row.cols.push(cellDef);
                    });
                    panel.rows.push(row);
                });
                panel.displayState = new BehaviorSubject(tabDef?.display ?? true);
                panel.display$ = panel.displayState.asObservable();
                panels.push(panel);
                if (isEmpty(record?.fields) || isEmpty(tabDef?.displayLogic)) {
                    return;
                }
                Object.values(tabDef.displayLogic).forEach((logicDef) => {
                    if (isEmpty(logicDef?.params?.fieldDependencies)) {
                        return;
                    }
                    logicDef.params.fieldDependencies.forEach((fieldKey) => {
                        const field = record.fields[fieldKey] || null;
                        if (isEmpty(field)) {
                            return;
                        }
                        this.fieldSubs.push(field.valueChanges$.subscribe(() => {
                            this.panelLogicManager.runLogic(logicDef.key, field, panel, record, this.getMode());
                        }));
                    });
                });
            });
            this.panelsSubject.next((this.panels = panels));
            return panels;
        });
        this.subs.push(panelSub);
    }
    clearSubpanels() {
        if (this.subpanels) {
            Object.keys(this.subpanels).forEach((key) => {
                this.subpanels[key].clear();
            });
        }
        if (this.subpanelReloadSub.length) {
            this.subpanelReloadSub.forEach((sub) => sub.unsubscribe());
            this.subpanelReloadSub = [];
        }
        this.subpanels = {};
    }
    /**
     * Calculate if widgets are to display
     */
    calculateShowWidgets() {
        let show = false;
        const recordViewMeta = this.getRecordViewMetadata();
        const sidebarWidgetsConfig = recordViewMeta.sidebarWidgets || [];
        if (sidebarWidgetsConfig && sidebarWidgetsConfig.length > 0) {
            show = true;
        }
        const showSidebarWidgets = this.loadPreference(this.getModuleName(), "show-sidebar-widgets") ?? null;
        if (showSidebarWidgets !== null) {
            this.showSidebarWidgets = showSidebarWidgets;
        }
        else {
            this.showSidebarWidgets = show;
        }
        this.widgets = show;
    }
    /**
     * Get record view metadata
     *
     * @returns {object} metadata RecordViewMetadata
     */
    getRecordViewMetadata() {
        const meta = this.metadataStore.get() || {};
        return meta.recordView || {};
    }
    /**
     * Get vardefs
     *
     * @returns {object} vardefs FieldDefinitionMap
     */
    getVardefs() {
        const meta = this.getRecordViewMetadata();
        return meta.vardefs || {};
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<ViewFieldDefinition[]>
     */
    getViewFieldsObservable() {
        return this.metadataStore.recordViewMetadata$.pipe(map((recordMetadata) => {
            const fieldsMap = {};
            recordMetadata.panels.forEach((panel) => {
                panel.rows.forEach((row) => {
                    row.cols.forEach((col) => {
                        const fieldName = col.name ?? col.fieldDefinition.name ?? "";
                        fieldsMap[fieldName] = col;
                    });
                });
            });
            Object.keys(recordMetadata.vardefs).forEach((fieldKey) => {
                const vardef = recordMetadata.vardefs[fieldKey] ?? null;
                if (!vardef || isEmpty(vardef)) {
                    return;
                }
                // already defined. skip
                if (fieldsMap[fieldKey]) {
                    return;
                }
                if (vardef.type == "relate") {
                    return;
                }
                fieldsMap[fieldKey] = {
                    name: fieldKey,
                    vardefBased: true,
                    label: vardef.vname ?? "",
                    type: vardef.type ?? "",
                    display: vardef.display ?? "",
                    fieldDefinition: vardef,
                    metadata: vardef.metadata ?? {},
                    logic: vardef.logic ?? {},
                };
            });
            return Object.values(fieldsMap);
        }));
    }
    getRecordMetadata$() {
        return this.metadataStore.recordViewMetadata$.pipe(map((recordMetadata) => {
            return recordMetadata?.metadata ?? {};
        }));
    }
    /**
     * Build ui user preference key
     *
     * @param {string} storageKey Storage Key
     * @protected
     * @returns {string} Preference Key
     */
    getPreferenceKey(storageKey) {
        return "recordview-" + storageKey;
    }
    /**
     * Save ui user preference
     *
     * @param {string} module Module
     * @param {string} storageKey Storage Key
     * @param {any} value Value
     * @protected
     */
    savePreference(module, storageKey, value) {
        this.preferences.setUi(module, this.getPreferenceKey(storageKey), value);
    }
    /**
     * Load ui user preference
     *
     * @param {string} module Module
     * @param {string} storageKey Storage Key
     * @protected
     * @returns {any} User Preference
     */
    loadPreference(module, storageKey) {
        return this.preferences.getUi(module, this.getPreferenceKey(storageKey));
    }
    safeUnsubscription(subscriptionArray) {
        subscriptionArray.forEach((sub) => {
            if (sub.closed) {
                return;
            }
            sub.unsubscribe();
        });
        subscriptionArray = [];
        return subscriptionArray;
    }
    setViewMode(mode) {
        this.viewModeSubject.next(mode);
    }
    static { this.ɵfac = function RecordViewStore_Factory(t) { return new (t || RecordViewStore)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(MessageService), i0.ɵɵinject(SubpanelStoreFactory), i0.ɵɵinject(RecordManager), i0.ɵɵinject(StatisticsBatch), i0.ɵɵinject(RecordStoreFactory), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(PanelLogicManager), i0.ɵɵinject(RecordConvertService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordViewStore, factory: RecordViewStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordViewStore, [{
        type: Injectable
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: AppStateStore }, { type: LanguageStore }, { type: NavigationStore }, { type: ModuleNavigation }, { type: MetadataStore }, { type: LocalStorageService }, { type: MessageService }, { type: SubpanelStoreFactory }, { type: RecordManager }, { type: StatisticsBatch }, { type: RecordStoreFactory }, { type: UserPreferenceStore }, { type: PanelLogicManager }, { type: RecordConvertService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function StatusBarComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3)(2, "div", 4);
    i0.ɵɵelement(3, "div", 5);
    i0.ɵɵelementStart(4, "div", 6)(5, "div", 7)(6, "div");
    i0.ɵɵtext(7, "Record Status Bar Component");
    i0.ɵɵelementEnd()()()()();
    i0.ɵɵelementContainerEnd();
} }
function StatusBarComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8)(1, "div", 9)(2, "div");
    i0.ɵɵtext(3, "Record Status Bar Component");
    i0.ɵɵelementEnd()()();
} }
class StatusBarComponent {
    constructor(recordViewStore, moduleNavigation) {
        this.recordViewStore = recordViewStore;
        this.moduleNavigation = moduleNavigation;
        this.displayResponsiveTable = false;
    }
    static { this.ɵfac = function StatusBarComponent_Factory(t) { return new (t || StatusBarComponent)(i0.ɵɵdirectiveInject(RecordViewStore), i0.ɵɵdirectiveInject(ModuleNavigation)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StatusBarComponent, selectors: [["scrm-status-bar"]], decls: 4, vars: 2, consts: [[1, "record-view-header"], [4, "ngIf"], [3, "ngIf"], [1, "d-flex", "flex-nowrap"], [1, "row"], [1, "w-100"], [1, "col"], [1, "order-2"], [1, "row", "mr-0"], [1, "col-md-4"]], template: function StatusBarComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementContainerStart(0);
            i0.ɵɵelementStart(1, "div", 0);
            i0.ɵɵtemplate(2, StatusBarComponent_ng_container_2_Template, 8, 0, "ng-container", 1);
            i0.ɵɵtemplate(3, StatusBarComponent_ng_template_3_Template, 4, 0, "ng-template", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementContainerEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.displayResponsiveTable);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.displayResponsiveTable);
        } }, dependencies: [i2.NgIf], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatusBarComponent, [{
        type: Component,
        args: [{ selector: 'scrm-status-bar', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container>\n    <div class=\"record-view-header\">\n        <ng-container *ngIf=\"displayResponsiveTable\">\n            <div class=\"d-flex flex-nowrap\">\n                <div class=\"row\">\n                    <div class=\"w-100\"></div>\n                    <div class=\"col\">\n                        <div class=\"order-2\">\n                            <div>Record Status Bar Component</div>\n                        </div>\n                    </div>\n                </div>\n            </div>\n        </ng-container>\n        <ng-template [ngIf]=\"!displayResponsiveTable\">\n            <div class=\"row mr-0\">\n                <div class=\"col-md-4\">\n                    <div>Record Status Bar Component</div>\n                </div>\n            </div>\n        </ng-template>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: RecordViewStore }, { type: ModuleNavigation }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const MONTH_YEAR_REGEX = new RegExp('^(\\d{4})-(0[1-9]|1[0-2])$');
const MONTH_REGEX = new RegExp('^(\\d{4})$');
class ListViewUrlQueryService {
    constructor(systemConfig, metadataStore, dataTypeFormatter) {
        this.systemConfig = systemConfig;
        this.metadataStore = metadataStore;
        this.dataTypeFormatter = dataTypeFormatter;
        /**
         * Array of allowed properties to be set to the searchCriteriaFieldFilter from url_query_filter_mapping
         */
        this.allowedProperties = [
            'operator',
            'target',
            'values',
            'start',
            'end'
        ];
        /**
         * An array containing properties that can be converted into dbFormat.
         */
        this.convertableProperties = [
            'target',
            'values',
            'start',
            'end'
        ];
    }
    /**
     * Builds a URL query-based filter.
     *
     * @param {string} module - The module name.
     * @param {SavedFilter} defaultFilter - The default filter.
     * @param {Params} rawQueryParams - The raw query parameters.
     * @returns {SavedFilter|null} - The built URL query-based filter, or null if no filter criteria are found.
     */
    buildUrlQueryBasedFilter(module, defaultFilter, rawQueryParams) {
        const filterFieldDefinitions = this.metadataStore.get().recordView.vardefs;
        const queryParams = Object.entries(rawQueryParams)
            .reduce((acc, [queryParamKey, queryParamVal]) => {
            const [cleanQueryParamKey, cleanQueryParamVal] = this.cleanQueryParam([
                queryParamKey,
                queryParamVal
            ]);
            acc[cleanQueryParamKey] = cleanQueryParamVal;
            return acc;
        }, {});
        const filterCriteria = this.getQueryFilterCriteria(filterFieldDefinitions, module, queryParams);
        if (isEmpty(filterCriteria.filters)) {
            return null;
        }
        return {
            key: 'default',
            searchModule: module,
            module: 'saved-search',
            criteria: filterCriteria
        };
    }
    /**
     * Generates the query filter criteria based on the provided field definitions map, module, and query parameters.
     *
     * @param {FieldDefinitionMap} fieldDefinitionMap - The field definition map.
     * @param {string} module - The module name.
     * @param {Params} queryParams - The query parameters.
     * @returns {SearchCriteria} - The generated search criteria.
     * @protected
     */
    getQueryFilterCriteria(fieldDefinitionMap, module, queryParams) {
        const criteria = {
            name: 'default',
            filters: {}
        };
        const queryParamsKeys = Object.keys(queryParams);
        const fieldDefinitions = Object.values(fieldDefinitionMap)
            .filter(({ name }) => queryParamsKeys.some(qPKey => qPKey.includes(name)));
        const listviewUrlQueryFilterMapping = this.systemConfig.getConfigValue('listview_url_query_filter_mapping');
        const listviewUrlQueryFilterMappingEntries = Object.entries(listviewUrlQueryFilterMapping);
        listviewUrlQueryFilterMappingEntries.push(['', {}]);
        let searchType;
        switch (queryParams['searchFormTab']) {
            case 'basic_search':
                searchType = 'basic';
                break;
            case 'advanced_search':
                searchType = 'advanced';
                break;
            default:
                searchType = 'advanced';
        }
        for (const fieldDefinition of fieldDefinitions) {
            const fieldFilterName = fieldDefinition.name;
            const fieldFilterKeys = [
                fieldFilterName,
                `${fieldFilterName}_${searchType}`
            ];
            for (const [queryFilterOperatorKeyTemplate, queryFilterOperatorParamsMap] of listviewUrlQueryFilterMappingEntries) {
                if (!isEmpty(criteria.filters[fieldFilterName])) {
                    break;
                }
                for (const fieldFilterKey of fieldFilterKeys) {
                    if (!isEmpty(criteria.filters[fieldFilterName])) {
                        break;
                    }
                    const searchCriteriaFieldFilter = this.buildSearchCriteriaFieldFilter(fieldFilterName, fieldDefinition.type, queryParams, fieldFilterKey, queryFilterOperatorKeyTemplate, queryFilterOperatorParamsMap);
                    if (isEmpty(searchCriteriaFieldFilter)) {
                        continue;
                    }
                    try {
                        this.convertableProperties.forEach((convertableProperty) => {
                            if (!searchCriteriaFieldFilter[convertableProperty]) {
                                return;
                            }
                            let internalFormatValue;
                            if (isArray(searchCriteriaFieldFilter[convertableProperty])) {
                                internalFormatValue = searchCriteriaFieldFilter[convertableProperty].map(prop => this.toInternalFormat(fieldDefinition.type, prop));
                            }
                            else {
                                internalFormatValue = this.toInternalFormat(fieldDefinition.type, searchCriteriaFieldFilter[convertableProperty]);
                            }
                            searchCriteriaFieldFilter[convertableProperty] = internalFormatValue;
                        });
                    }
                    catch (e) {
                        continue;
                    }
                    criteria.filters[fieldFilterName] = searchCriteriaFieldFilter;
                }
            }
        }
        return criteria;
    }
    /**
     * Builds a search criteria field filter object based on the provided parameters.
     *
     * @param {string} fieldFilterName - The name of the field filter.
     * @param {string} fieldFilterFieldType - The type of the field filter.
     * @param {Params} queryParams - The query parameters.
     * @param {string} fieldFilterKey - The key of the field filter in the query parameters.
     * @param {string} queryFilterOperatorKeyTemplate - The template for the query filter operator key.
     * @param {NestedGenericMap<string>} queryFilterOperatorParamsMap - The map of query filter operator keys to their respective parameter maps.
     * @returns {SearchCriteriaFieldFilter | null} The built search criteria field filter object.
     * @protected
     */
    buildSearchCriteriaFieldFilter(fieldFilterName, fieldFilterFieldType, queryParams, fieldFilterKey, queryFilterOperatorKeyTemplate, queryFilterOperatorParamsMap) {
        const searchCriteriaFieldFilter = {
            field: fieldFilterName,
            fieldType: fieldFilterFieldType,
            operator: '=',
            values: []
        };
        if (isEmpty(queryFilterOperatorKeyTemplate) || isEmpty(queryFilterOperatorParamsMap)) {
            const fieldFilterValue = this.getQueryParamValue(fieldFilterKey, fieldFilterKey, queryParams);
            if (isEmpty(fieldFilterValue) && !isEmptyString(fieldFilterValue)) {
                return null;
            }
            const values = isArray(fieldFilterValue)
                ? fieldFilterValue
                : [fieldFilterValue];
            searchCriteriaFieldFilter.values = values;
            searchCriteriaFieldFilter.target = values[0];
            return this.checkDateSpecialsOrReturn(searchCriteriaFieldFilter, searchCriteriaFieldFilter.target);
        }
        const queryFilterOperatorKey = this.getQueryParamValue(queryFilterOperatorKeyTemplate, fieldFilterKey, queryParams, { forceSingleString: true });
        const queryFilterOperatorParams = (queryFilterOperatorParamsMap[queryFilterOperatorKey] ??
            Object
                .values(queryFilterOperatorParamsMap)
                .reduce((prev, curr) => ({ ...prev, ...curr }), {})
            ?? {});
        if (isEmpty(queryFilterOperatorParams)) {
            return null;
        }
        let returnEmpty = true;
        searchCriteriaFieldFilter.operator = queryFilterOperatorKey;
        Object.entries(queryFilterOperatorParams)
            .filter(([_, searchCriteriaPropertyKey]) => (typeof searchCriteriaPropertyKey === 'string'
            && this.allowedProperties.includes(searchCriteriaPropertyKey)))
            .forEach(([searchCriteriaPropertyValueTemplate, searchCriteriaPropertyKey]) => {
            const rawSearchCriteriaPropertyValue = this.getQueryParamValue(searchCriteriaPropertyValueTemplate, fieldFilterKey, queryParams);
            if (isEmpty(rawSearchCriteriaPropertyValue)) {
                return;
            }
            returnEmpty = false;
            let searchCriteriaPropertyValue = rawSearchCriteriaPropertyValue;
            if (searchCriteriaPropertyKey === 'values') {
                if (!isArray(searchCriteriaPropertyValue)) {
                    searchCriteriaPropertyValue = [searchCriteriaPropertyValue];
                }
                searchCriteriaFieldFilter['target'] = searchCriteriaPropertyValue[0];
            }
            else if (searchCriteriaPropertyKey === 'target') {
                if (isArray(searchCriteriaPropertyValue)) {
                    searchCriteriaPropertyValue = searchCriteriaPropertyValue[0];
                }
                searchCriteriaFieldFilter['values'] = [searchCriteriaPropertyValue];
            }
            searchCriteriaFieldFilter[searchCriteriaPropertyKey] = searchCriteriaPropertyValue;
            if (!isArray(searchCriteriaPropertyValue)) {
                this.checkDateSpecialsOrReturn(searchCriteriaFieldFilter, searchCriteriaPropertyValue, {
                    operator: queryFilterOperatorKey,
                    key: searchCriteriaPropertyKey
                });
            }
        });
        return !returnEmpty ? this.checkForMissingOperator(searchCriteriaFieldFilter) : null;
    }
    /**
     * Retrieves the value of a query parameter based on the provided queryParamKeyTemplate,
     * fieldFilterKey, and queryParams.
     *
     * @param {string} queryParamKeyTemplate - The template for the query parameter key, with "{field}" as a placeholder for fieldFilterKey.
     * @param {string} fieldFilterKey - The field filter key used to replace the "{field}" placeholder in queryParamKeyTemplate.
     * @param {Params} queryParams - The object containing the query parameters.
     * @param {object} options - Optional parameters to customize the behavior of the method.
     * @param {boolean} options.forceSingleString - Flag indicating whether the result should always be a single string value.
     * @returns {string|string[]} - The value of the query parameter. If forceSingleString is false, it will be either a string or an array of strings.
     * @protected
     */
    getQueryParamValue(queryParamKeyTemplate, fieldFilterKey, queryParams, { forceSingleString = false } = {}) {
        const queryParamKey = queryParamKeyTemplate.replace('{field}', fieldFilterKey) ?? '';
        let queryParamValue = queryParams[queryParamKey];
        if (!queryParamValue) {
            return null;
        }
        if (isArray(queryParamValue)) {
            queryParamValue = queryParamValue.map(this.transform);
        }
        else {
            queryParamValue = this.transform(queryParamValue);
        }
        if (forceSingleString && isArray(queryParamValue)) {
            return queryParamValue[0] ?? '';
        }
        return queryParamValue;
    }
    /**
     * Cleans the query parameter key by removing the '[]' brackets if present.
     *
     * @returns {string} - The cleaned query parameter key.
     * @protected
     * @param queryParam
     */
    cleanQueryParam(queryParam) {
        let [queryParamKey, queryParamVal] = queryParam;
        const queryParamKeyReversed = queryParamKey.split('').reverse().join('');
        if (queryParamKeyReversed.indexOf('][') === 0 && typeof queryParamVal === 'string') {
            queryParamKey = queryParamKey.replace('[]', '');
            queryParamVal = queryParamVal.split(',');
        }
        return [queryParamKey, queryParamVal];
    }
    /**
     * Checks if given fieldFilterValue matches MONTH_YEAR_REGEX or yearRegex and returns
     * overridesSearchCriteriaFieldFilter if true, else returns searchCriteriaFieldFilter.
     *
     * @param {SearchCriteriaFieldFilter} searchCriteriaFieldFilter - The search criteria field filter.
     * @param {string} fieldFilterValue - The field filter value.
     * @param {Object} options - The options object.
     * @param {string} [options.operator='='] - The range option.
     * @param {string} [options.key='target'] - The key option.
     * @returns {SearchCriteriaFieldFilter} - The updated search criteria field filter.
     * @protected
     */
    checkDateSpecialsOrReturn(searchCriteriaFieldFilter, fieldFilterValue, { operator = '=', key = 'target' } = {}) {
        if (fieldFilterValue.match(MONTH_YEAR_REGEX)) {
            return this.overridesSearchCriteriaFieldFilter(searchCriteriaFieldFilter, fieldFilterValue, { type: 'month', operator, key });
        }
        if (fieldFilterValue.match(MONTH_REGEX)) {
            return this.overridesSearchCriteriaFieldFilter(searchCriteriaFieldFilter, fieldFilterValue, { type: 'year', operator, key });
        }
        return searchCriteriaFieldFilter;
    }
    /**
     * Overrides the search criteria field filter based on the provided parameters.
     *
     * @param {SearchCriteriaFieldFilter} searchCriteriaFieldFilter - The original search criteria field filter.
     * @param {string} fieldFilterValue - The value of the field filter.
     * @param {Object} options - The options for overriding the field filter.
     * @param {string} options.type - The type of the field filter.
     * @param {string} [options.operator='equal'] - The operator for the field filter.
     * @param {string} [options.key='target'] - The key for the field filter.
     * @protected
     * @returns {SearchCriteriaFieldFilter} - The overridden search criteria field filter.
     */
    overridesSearchCriteriaFieldFilter(searchCriteriaFieldFilter, fieldFilterValue, { type = '', operator = 'equal', key = 'target' }) {
        let plusObject;
        let fmt;
        switch (type) {
            case 'year':
                plusObject = { year: 1 };
                fmt = 'yyyy';
                break;
            case 'month':
                plusObject = { month: 1 };
                fmt = 'yyyy-MM';
                break;
            default:
                return searchCriteriaFieldFilter;
        }
        const start = DateTime.fromFormat(fieldFilterValue, fmt);
        const end = start.plus(plusObject).minus({ day: 1 });
        if (key !== 'target') {
            switch (key) {
                case 'start':
                    searchCriteriaFieldFilter.start = start.toFormat('yyyy-MM-dd');
                    break;
                case 'end':
                    searchCriteriaFieldFilter.end = end.toFormat('yyyy-MM-dd');
                    break;
            }
            return searchCriteriaFieldFilter;
        }
        searchCriteriaFieldFilter.operator = operator;
        switch (operator) {
            case 'greater_than':
            case 'greater_than_equals':
                searchCriteriaFieldFilter.start = start.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.target = searchCriteriaFieldFilter.start;
                searchCriteriaFieldFilter.values = [searchCriteriaFieldFilter.target];
                break;
            case 'less_than':
            case 'less_than_equals':
                searchCriteriaFieldFilter.end = end.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.target = searchCriteriaFieldFilter.end;
                searchCriteriaFieldFilter.values = [searchCriteriaFieldFilter.target];
                break;
            case 'not_equal':
                searchCriteriaFieldFilter.start = start.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.end = end.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.target = fieldFilterValue;
                searchCriteriaFieldFilter.values = [fieldFilterValue];
                break;
            case 'equal':
            case 'between':
            default:
                searchCriteriaFieldFilter.operator = 'between';
                searchCriteriaFieldFilter.start = start.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.end = end.toFormat('yyyy-MM-dd');
                searchCriteriaFieldFilter.target = '';
                searchCriteriaFieldFilter.values = [];
                break;
        }
        return searchCriteriaFieldFilter;
    }
    /**
     * Converts the given value to the internal format based on the specified type.
     *
     * @param {string} type - The type of value to convert to.
     * @param {string} value - The value to convert.
     * @return {string} - The converted value in the internal format.
     * @protected
     */
    toInternalFormat(type, value) {
        if (value.match(MONTH_REGEX) || value.match(MONTH_YEAR_REGEX)) {
            return value;
        }
        return this.dataTypeFormatter.toInternalFormat(type, value);
    }
    ;
    /**
     * Transforms the given value from url to a value understandable by backend.
     *
     * @param {any} value - The value to be transformed.
     * @protected
     * @return {string} The transformed value.
     */
    transform(value) {
        switch (value) {
            case '':
                return '__SuiteCRMEmptyString__';
            default:
                return value;
        }
    }
    checkForMissingOperator(searchCriteriaFieldFilter) {
        if (!isEmpty(searchCriteriaFieldFilter.start)
            && !isEmpty(searchCriteriaFieldFilter.end)) {
            searchCriteriaFieldFilter.operator = 'between';
        }
        return searchCriteriaFieldFilter;
    }
    static { this.ɵfac = function ListViewUrlQueryService_Factory(t) { return new (t || ListViewUrlQueryService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(DataTypeFormatter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewUrlQueryService, factory: ListViewUrlQueryService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewUrlQueryService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: MetadataStore }, { type: DataTypeFormatter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialFilter = {
    key: 'default',
    module: 'saved-search',
    attributes: {
        contents: ''
    },
    criteria: {
        name: 'default',
        filters: {}
    }
};
const initialFilters = {
    'default': deepClone(initialFilter)
};
const initialState$6 = {
    module: '',
    widgets: true,
    actionPanel: '',
    showSidebarWidgets: false,
    recordPanelConfig: {},
    activeFilters: deepClone(initialFilters),
    openFilter: deepClone(initialFilter)
};
class ListViewStore extends ViewStore {
    constructor(appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore, message, listStoreFactory, modalService, filterListStoreFactory, confirmation, preferences, route, listViewUrlQueryService, localStorageService, systemConfigsStore, userPreferences) {
        super(appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore);
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.moduleNavigation = moduleNavigation;
        this.metadataStore = metadataStore;
        this.message = message;
        this.listStoreFactory = listStoreFactory;
        this.modalService = modalService;
        this.filterListStoreFactory = filterListStoreFactory;
        this.confirmation = confirmation;
        this.preferences = preferences;
        this.route = route;
        this.listViewUrlQueryService = listViewUrlQueryService;
        this.localStorageService = localStorageService;
        this.systemConfigsStore = systemConfigsStore;
        this.userPreferences = userPreferences;
        this.pageKey = 'listview';
        /** Internal Properties */
        this.cache$ = null;
        this.internalState = deepClone(initialState$6);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subs = [];
        this.recordList = this.listStoreFactory.create();
        this.columns$ = metadataStore.listViewColumns$;
        this.lineActions$ = metadataStore.listViewLineActions$;
        this.tableActions$ = metadataStore.listViewTableActions$;
        this.records$ = this.recordList.records$;
        this.criteria$ = this.recordList.criteria$;
        this.context$ = this.recordList.criteria$.pipe(map(() => this.getViewContext()));
        this.sort$ = this.recordList.sort$;
        this.pagination$ = this.recordList.pagination$;
        this.selection$ = this.recordList.selection$;
        this.selectedCount$ = this.recordList.selectedCount$;
        this.selectedStatus$ = this.recordList.selectedStatus$;
        this.loading$ = this.recordList.loading$;
        this.moduleName$ = this.state$.pipe(map(state => state.module), distinctUntilChanged());
        this.widgets$ = this.state$.pipe(map(state => state.widgets), distinctUntilChanged());
        this.showSidebarWidgets$ = this.state$.pipe(map(state => state.showSidebarWidgets));
        this.displayFilters$ = this.state$.pipe(map(state => state.actionPanel === 'filters'), distinctUntilChanged());
        this.actionPanel$ = this.state$.pipe(map(state => state.actionPanel), distinctUntilChanged());
        this.activeFilters$ = this.state$.pipe(map(state => state.activeFilters), distinctUntilChanged());
        this.openFilter$ = this.state$.pipe(map(state => state.openFilter), distinctUntilChanged());
        const data$ = this.records$.pipe(combineLatestWith(this.criteria$, this.pagination$, this.selection$, this.loading$), map(([records, criteria, pagination, selection, loading]) => {
            this.data = { records, criteria, pagination, selection, loading };
            return this.data;
        }));
        this.vm$ = data$.pipe(combineLatestWith(this.appData$, this.metadata$), map(([data, appData, metadata]) => {
            this.vm = { data, appData, metadata };
            return this.vm;
        }));
        this.columns = new BehaviorSubject([]);
        this.columns$ = this.columns.asObservable();
        this.initDataUpdateState();
        this.initDataSetUpdatedState();
        this.filterList = this.filterListStoreFactory.create();
        this.recordList.pageKey = this.pageKey;
    }
    get actionPanel() {
        return this.internalState.actionPanel;
    }
    get showFilters() {
        return this.internalState.actionPanel === 'filters';
    }
    set showFilters(show) {
        this.updateState({
            ...this.internalState,
            actionPanel: show ? 'filters' : ''
        });
    }
    get widgets() {
        return this.internalState.widgets;
    }
    set widgets(show) {
        this.updateState({
            ...this.internalState,
            widgets: show
        });
    }
    get showSidebarWidgets() {
        return this.internalState.showSidebarWidgets;
    }
    set showSidebarWidgets(show) {
        this.savePreference(this.getModuleName(), 'show-sidebar-widgets', show);
        this.updateState({
            ...this.internalState,
            showSidebarWidgets: show
        });
    }
    get recordPanelConfig() {
        return this.internalState.recordPanelConfig;
    }
    isRecordPanelOpen() {
        return this.internalState.actionPanel === 'recordPanel';
    }
    openRecordPanel(config) {
        this.updateState({
            ...this.internalState,
            actionPanel: 'recordPanel',
            recordPanelConfig: config
        });
    }
    closeRecordPanel() {
        this.updateState({
            ...this.internalState,
            actionPanel: '',
            recordPanelConfig: {}
        });
    }
    getModuleName() {
        return this.internalState.module;
    }
    getViewContext() {
        const context = {
            module: this.getModuleName(),
        };
        context.criteria = this.recordList.criteria;
        context.sort = this.recordList.sort;
        return context;
    }
    /**
     * Clean destroy
     */
    destroy() {
        this.clear();
        this.subs.forEach(sub => sub.unsubscribe());
    }
    /**
     * get active filters
     *
     * @returns {object} active filters
     */
    get activeFilters() {
        return deepClone(this.internalState.activeFilters);
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.cache$ = null;
        this.updateState(deepClone(initialState$6));
        this.recordList.clear();
    }
    clearAuthBased() {
        this.clear();
        this.recordList.clearAuthBased();
    }
    /**
     * Initial list records load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @returns {object} Observable<any>
     */
    init(module) {
        this.internalState.module = module;
        this.recordList.init(module, false);
        this.filterList.init(module);
        this.filterList.load(false).pipe(take(1)).subscribe();
        this.calculateShowWidgets();
        this.recordList.sort = {
            orderBy: this?.metadata?.listView?.orderBy ?? '',
            sortOrder: this?.metadata?.listView?.sortOrder ?? 'NONE'
        };
        const queryParams = this.route?.snapshot?.queryParams ?? {};
        let filterType = '';
        if (isTrue(queryParams['query'])) {
            filterType = 'query';
        }
        switch (filterType) {
            case 'query':
                this.loadQueryFilter(module, queryParams);
                break;
            default:
                this.loadCurrentFilter(module);
                this.loadCurrentSort(module);
        }
        this.loadCurrentDisplayedColumns();
        const paginationType = this.userPreferences.getUserPreference('listview_pagination_type') ?? this.systemConfigsStore.getConfigValue('listview_pagination_type');
        const currentPaginationType = this.getCurrentPaginationType(module);
        this.setCurrentPaginationType(module, paginationType);
        if (queryParams['keepPagination'] && currentPaginationType === paginationType) {
            this.loadCurrentPagination(module);
        }
        return this.load();
    }
    /**
     * Set open filters
     *
     * @param {object} filter to set
     */
    setOpenFilter(filter) {
        this.updateState({ ...this.internalState, openFilter: deepClone(filter) });
    }
    /**
     * Toggle Quick filter
     *
     * @param filter
     * @param {boolean} reload flag
     */
    toggleQuickFilter(filter, reload = true) {
        let activeFilters = this.getActiveQuickFilters();
        const isActive = Object.keys(activeFilters).some(key => key === filter.key);
        if (isActive) {
            let { [filter.key]: removedFilters, ...newFilters } = activeFilters;
            activeFilters = newFilters;
        }
        else {
            activeFilters = {};
            activeFilters[filter.key] = filter;
        }
        if (emptyObject(activeFilters)) {
            this.resetFilters(reload);
            return;
        }
        if (Object.keys(activeFilters).length === 1) {
            this.setFilters(activeFilters);
            return;
        }
        this.updateState({
            ...this.internalState,
            activeFilters: deepClone(activeFilters),
        });
        this.updateSearchCriteria(reload);
    }
    /**
     * Set active filters
     *
     * @param {object} filters to set
     * @param {boolean} reload flag
     * @param sort
     */
    setFilters(filters, reload = true, sort = null) {
        const filterKey = Object.keys(filters).shift();
        const filter = filters[filterKey];
        this.updateState({ ...this.internalState, activeFilters: deepClone(filters), openFilter: deepClone(filter) });
        if (filter.criteria) {
            let orderBy = filter.criteria.orderBy ?? '';
            const sortOrder = filter.criteria.sortOrder ?? '';
            let direction = this.recordList.mapSortOrder(sortOrder);
            if (sort !== null) {
                orderBy = sort.orderBy;
                direction = sort.sortOrder;
            }
            this.recordList.updateSorting(orderBy, direction, false);
            this.updateSortLocalStorage();
        }
        this.updateSearchCriteria(reload);
    }
    /**
     * Update filters
     *
     * @param {object} filter to set
     */
    addSavedFilter(filter) {
        const newState = { ...this.internalState };
        const activeFilters = this.activeFilters;
        if (filter.key && activeFilters[filter.key]) {
            activeFilters[filter.key] = filter;
            newState.activeFilters = activeFilters;
        }
        newState.openFilter = filter;
        this.filterList.addFilter(filter);
        this.updateState(newState);
    }
    /**
     * Update filters
     *
     * @param {object} filter to set
     */
    removeSavedFilter(filter) {
        if (!filter || !filter.key) {
            return;
        }
        this.filterList.removeFilter(filter);
        const newState = { ...this.internalState };
        if (newState.openFilter && newState.openFilter.key === filter.key) {
            this.resetFilters(true);
        }
    }
    /**
     * Reset active filters
     *
     * @param {boolean} reload flag
     */
    resetFilters(reload = true) {
        this.updateState({
            ...this.internalState,
            activeFilters: deepClone(initialFilters),
            openFilter: deepClone(initialFilter),
        });
        this.recordList.clearSort();
        this.updateSortLocalStorage();
        this.updateSearchCriteria(reload);
    }
    /**
     * Update the search criteria
     *
     * @param {boolean} reload flag
     */
    updateSearchCriteria(reload = true) {
        const filters = { ...this.internalState.activeFilters };
        let criteria = this.mergeCriteria(filters);
        this.recordList.updateSearchCriteria(criteria, reload);
        this.updateFilterLocalStorage();
    }
    updateFilterLocalStorage() {
        const module = this.internalState.module;
        this.savePreference(module, 'current-filters', this.internalState.activeFilters);
    }
    updateSortLocalStorage() {
        const module = this.internalState.module;
        this.savePreference(module, 'current-sort', this.recordList.sort);
    }
    updatePaginationLocalStorage() {
        const module = this.internalState.module;
        const key = module + '-' + this.getPreferenceKey('current-pagination');
        this.localStorageService.set(key, this.recordList.pagination);
    }
    /**
     * Updated displayed columns' ui user preference
     * @param display
     */
    updateDisplayedColumnsPreference(display) {
        const module = this.internalState.module;
        this.savePreference(module, 'displayed-columns', display);
    }
    /**
     * Get displayed columns' ui user preference
     */
    getDisplayedColumnsPreference() {
        const module = this.internalState.module;
        const displayedColumns = this.loadPreference(module, 'displayed-columns');
        if (!isArray(displayedColumns) || !displayedColumns || !displayedColumns.length) {
            return null;
        }
        return displayedColumns;
    }
    triggerDataUpdate() {
        this.dataUpdateState.next(true);
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<ListViewState>
     */
    load(useCache = true) {
        const module = this.internalState.module;
        this.savePreference(module, 'current-filters', this.internalState.activeFilters);
        this.savePreference(module, 'current-sort', this.recordList.sort);
        this.updatePaginationLocalStorage();
        return this.recordList.load(useCache);
    }
    /**
     * Internal API
     */
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Get Active quick filters
     * @protected
     */
    getActiveQuickFilters() {
        let { 'default': defaultFilter, ...currentQuickFilters } = this.activeFilters;
        let activeFilters = {};
        Object.keys(currentQuickFilters).forEach(key => {
            const activeFilter = currentQuickFilters[key] ?? null;
            if (!key) {
                return;
            }
            const isQuickFilter = activeFilter?.attributes?.quick_filter ?? false;
            if (isQuickFilter) {
                activeFilters[key] = activeFilter;
            }
        });
        return activeFilters;
    }
    /**
     * Merge Criteria
     * @protected
     */
    mergeCriteria(filters) {
        let criteria = {};
        const keys = Object.keys(filters ?? {}) ?? [];
        keys.forEach(key => {
            const filter = filters[key] ?? null;
            const filterCriteria = filter?.criteria ?? null;
            const filterCriteriaKeys = Object.keys(filterCriteria?.filters ?? {});
            if (filterCriteria === null || (filterCriteriaKeys && !filterCriteriaKeys.length)) {
                return;
            }
            if (emptyObject(criteria)) {
                criteria = deepClone(filterCriteria);
                return;
            }
            filterCriteriaKeys.forEach(criteriaKey => {
                const filterCriteriaContent = filterCriteria?.filters[criteriaKey] ?? null;
                const criteriaContent = criteria?.filters[criteriaKey] ?? null;
                if (!filterCriteriaContent) {
                    return;
                }
                const criteriaOperator = criteriaContent?.operator ?? null;
                if (!criteriaContent || !criteriaOperator) {
                    criteria.filters[criteriaKey] = deepClone(filterCriteriaContent);
                    return;
                }
                const filterCriteriaOperator = filterCriteriaContent?.operator ?? null;
                if (filterCriteriaOperator !== criteriaOperator || filterCriteriaOperator !== '=') {
                    delete criteria.filters[criteriaKey];
                    return;
                }
                criteriaContent.values = union(criteriaContent.values ?? [], filterCriteriaContent.values ?? []);
            });
        });
        return criteria;
    }
    /**
     * Open columns chooser modal
     */
    openColumnChooserDialog() {
        const modalRef = this.modalService.open(ColumnChooserComponent, {
            ariaLabelledBy: 'modal-basic-title',
            centered: true,
            size: 'lg',
            windowClass: 'column-chooser-modal'
        });
        const displayedColumns = this.columns.getValue().filter(function (col) {
            return !col.hasOwnProperty('default')
                || (col.hasOwnProperty('default') && col.default === true);
        });
        const hiddenColumns = this.columns.getValue().filter(function (col) {
            return col.hasOwnProperty('default') && col.default === false;
        });
        modalRef.componentInstance.displayed = displayedColumns;
        modalRef.componentInstance.hidden = hiddenColumns;
        modalRef.result.then((result) => {
            if (!result.displayed || !result.hidden) {
                return;
            }
            let allColumns = [];
            const selectedDisplayColumns = result.displayed;
            const selectedHideColumns = result.hidden;
            selectedDisplayColumns.forEach(function (column) {
                column.default = true;
            });
            selectedHideColumns.forEach(function (column) {
                column.default = false;
            });
            allColumns.push(...selectedDisplayColumns, ...selectedHideColumns);
            this.columns.next(allColumns);
            const displayedCols = selectedDisplayColumns.map(col => col.name);
            this.updateDisplayedColumnsPreference(displayedCols);
        });
    }
    /**
     * Calculate if widgets are to display
     */
    calculateShowWidgets() {
        let show = false;
        const meta = this.metadataStore.get() || {};
        const listViewMeta = meta.listView || {};
        const sidebarWidgetsConfig = listViewMeta.sidebarWidgets || [];
        if (sidebarWidgetsConfig && sidebarWidgetsConfig.length > 0) {
            show = true;
        }
        const showSidebarWidgets = this.loadPreference(this.getModuleName(), 'show-sidebar-widgets') ?? null;
        if (showSidebarWidgets !== null) {
            this.showSidebarWidgets = showSidebarWidgets;
        }
        else {
            this.showSidebarWidgets = show;
        }
        this.widgets = show;
    }
    /**
     * Build ui user preference key
     * @param storageKey
     * @protected
     */
    getPreferenceKey(storageKey) {
        return this.pageKey + '-' + storageKey;
    }
    /**
     * Save ui user preference
     * @param module
     * @param storageKey
     * @param value
     * @protected
     */
    savePreference(module, storageKey, value) {
        this.preferences.setUi(module, this.getPreferenceKey(storageKey), value);
    }
    /**
     * Load ui user preference
     * @param module
     * @param storageKey
     * @protected
     */
    loadPreference(module, storageKey) {
        return this.preferences.getUi(module, this.getPreferenceKey(storageKey));
    }
    /**
     * Load current filter
     * @param module
     * @protected
     */
    loadCurrentFilter(module) {
        const activeFiltersPref = this.loadPreference(module, 'current-filters') ?? {};
        if (!activeFiltersPref || emptyObject(activeFiltersPref)) {
            return;
        }
        let currentSort = this.loadPreference(module, 'current-sort');
        if (!currentSort && emptyObject(currentSort)) {
            currentSort = null;
        }
        this.setFilters(activeFiltersPref, false, currentSort);
    }
    /**
     * Load current filter
     * @param module
     * @param queryParams
     * @protected
     */
    loadQueryFilter(module, queryParams) {
        const orderBy = queryParams['orderBy'] ?? '';
        const sortOrder = queryParams['sortOrder'] ?? '';
        const direction = this.recordList.mapSortOrder(sortOrder);
        const filter = this.listViewUrlQueryService.buildUrlQueryBasedFilter(module, this.internalState.activeFilters.default, queryParams);
        if (isEmpty(filter)) {
            return;
        }
        const filters = { 'default': filter };
        this.updateState({
            ...this.internalState,
            activeFilters: deepClone(filters),
            openFilter: deepClone(filter)
        });
        this.recordList.updateSorting(orderBy, direction, false);
        this.recordList.updateSearchCriteria(filter.criteria, false);
    }
    /**
     * Load current sorting
     * @param module
     * @protected
     */
    loadCurrentSort(module) {
        const currentSort = this.loadPreference(module, 'current-sort');
        if (!currentSort || emptyObject(currentSort)) {
            return;
        }
        this.recordList.sort = currentSort;
    }
    /**
     * Load current pagination
     * @param module
     * @protected
     */
    loadCurrentPagination(module) {
        const key = module + '-' + this.getPreferenceKey('current-pagination');
        const currentPagination = this.localStorageService.get(key);
        if (!currentPagination || emptyObject(currentPagination)) {
            return;
        }
        this.recordList.pagination = currentPagination;
    }
    /**
     * Get current pagination Type
     * @param module
     * @protected
     */
    getCurrentPaginationType(module) {
        const currentPaginationType = this.loadPreference(module, 'current-pagination-type');
        if (!currentPaginationType) {
            return 'pagination';
        }
        return currentPaginationType;
    }
    /**
     * Set current pagination Type
     * @param module
     * @protected
     */
    setCurrentPaginationType(module, paginationType) {
        this.savePreference(module, 'current-pagination-type', paginationType);
    }
    /**
     * Load current displayed columns
     * @protected
     */
    loadCurrentDisplayedColumns() {
        this.metadataStore.listViewColumns$.pipe(take(1)).subscribe(cols => {
            const displayedColumns = this.getDisplayedColumnsPreference();
            if (!displayedColumns || !cols) {
                this.columns.next(cols);
                return;
            }
            const colMap = {};
            displayedColumns.forEach(displayedColumn => {
                colMap[displayedColumn] = true;
            });
            const displayedMap = {};
            const hidden = [];
            cols.forEach(col => {
                col.default = colMap[col.name] ?? false;
                if (col.default) {
                    displayedMap[col.name] = col;
                }
                else {
                    hidden.push(col);
                }
            });
            const displayed = displayedColumns.filter(col => !!displayedMap[col]).map(col => displayedMap[col]);
            this.columns.next([...displayed, ...hidden]);
        });
    }
    /**
     * Initialize data update state.
     * It should be emitted on any change in values on the record list.
     * Reload/Pagination is not considered as a data update
     */
    initDataUpdateState() {
        this.dataUpdateState = new BehaviorSubject(true);
        this.dataUpdate$ = this.dataUpdateState.asObservable();
    }
    /**
     *  Initialize the dataSet update state.
     *  It should be emitted on any change in dataSet e.g. due to data filter, due to data delete,
     *  due to data edit or any event which causes change in the resulting dataSet.
     */
    initDataSetUpdatedState() {
        this.dataSetUpdate$ = this.criteria$.pipe(combineLatestWith(this.dataUpdate$), map(() => true));
    }
    static { this.ɵfac = function ListViewStore_Factory(t) { return new (t || ListViewStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(FilterListStoreFactory), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(i1$2.ActivatedRoute), i0.ɵɵinject(ListViewUrlQueryService), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewStore, factory: ListViewStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewStore, [{
        type: Injectable
    }], function () { return [{ type: AppStateStore }, { type: LanguageStore }, { type: NavigationStore }, { type: ModuleNavigation }, { type: MetadataStore }, { type: MessageService }, { type: RecordListStoreFactory }, { type: i3$1.NgbModal }, { type: FilterListStoreFactory }, { type: ConfirmationModalService }, { type: UserPreferenceStore }, { type: i1$2.ActivatedRoute }, { type: ListViewUrlQueryService }, { type: LocalStorageService }, { type: SystemConfigStore }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ActionMenuComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelement(1, "scrm-button-group", 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config$", ctx_r0.config$);
} }
class ActionMenuComponent {
    constructor(listStore, actionHandler, screenSize, systemConfigs, asyncActionService) {
        this.listStore = listStore;
        this.actionHandler = actionHandler;
        this.screenSize = screenSize;
        this.systemConfigs = systemConfigs;
        this.asyncActionService = asyncActionService;
        this.configState = new BehaviorSubject({ buttons: [] });
        this.config$ = this.configState.asObservable();
        this.vm$ = this.screenSize.screenSize$.pipe(map((screenSize) => {
            if (screenSize) {
                this.screen = screenSize;
            }
            this.configState.next(this.getButtonGroupConfig());
            return { screenSize };
        }));
        this.screen = ScreenSize.Medium;
        this.defaultBreakpoint = 3;
    }
    ngOnInit() {
        this.configState.next(this.getButtonGroupConfig());
    }
    getButtonGroupConfig() {
        const actions = this.actions;
        const config = {
            buttonKlass: ['action-button'],
            dropdownLabel: this.listStore.appStrings.LBL_MORE || '',
            buttons: [],
            dropdownOptions: {
                placement: ['bottom-right']
            },
            breakpoint: this.getBreakpoint()
        };
        actions.forEach(action => {
            const buttonConfig = this.getButtonConfig(action);
            if (buttonConfig && buttonConfig.klass) {
                config.buttons.push(buttonConfig);
            }
        });
        return config;
    }
    getBreakpoint() {
        const breakpointMap = this.systemConfigs && this.systemConfigs.getConfigValue('listview_actions_limits');
        if (this.screen && breakpointMap && breakpointMap[this.screen]) {
            this.breakpoint = breakpointMap[this.screen];
            return this.breakpoint;
        }
        if (this.breakpoint) {
            return this.breakpoint;
        }
        return this.defaultBreakpoint;
    }
    get actions() {
        if (!this.listStore.vm.appData.module || !this.listStore.vm.appData.module.menu) {
            return [];
        }
        return this.listStore.vm.appData.module.menu.filter(action => !(action.name === 'List' || action.name === 'View'));
    }
    getButtonConfig(action) {
        if (!this.listStore.vm.appData.appState.module) {
            return {};
        }
        if (!this.listStore.vm.appData.language) {
            return {};
        }
        const module = this.listStore.vm.appData.appState.module;
        const language = this.listStore.vm.appData.language;
        let labelKey = '';
        if (action.actionLabelKey) {
            labelKey = action.actionLabelKey;
        }
        return {
            klass: 'action-button',
            label: this.actionHandler.getActionLabel(module, action, language, labelKey),
            onClick: () => {
                if (action?.process) {
                    this.handleProcess(module, action?.process);
                    return;
                }
                this.actionHandler.navigate(action).then();
            }
        };
    }
    handleProcess(moduleName, process) {
        if (!process) {
            return;
        }
        const processType = process;
        const options = {
            action: processType,
            module: moduleName,
        };
        this.asyncActionService.run(processType, options).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function ActionMenuComponent_Factory(t) { return new (t || ActionMenuComponent)(i0.ɵɵdirectiveInject(ListViewStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(AsyncActionService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ActionMenuComponent, selectors: [["scrm-action-menu"]], decls: 2, vars: 3, consts: [["class", "list-view-actions float-right", 4, "ngIf"], [1, "list-view-actions", "float-right"], [3, "config$"]], template: function ActionMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ActionMenuComponent_div_0_Template, 2, 1, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, ButtonGroupComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-action-menu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"list-view-actions float-right\" *ngIf=\"(vm$ | async) as vm\">\n    <scrm-button-group [config$]=\"config$\"></scrm-button-group>\n</div>\n" }]
    }], function () { return [{ type: ListViewStore }, { type: ModuleNavigation }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }, { type: AsyncActionService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ActionMenuModule {
    static { this.ɵfac = function ActionMenuModule_Factory(t) { return new (t || ActionMenuModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ActionMenuModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModalModule,
            ButtonModule,
            AngularSvgIconModule,
            ButtonGroupModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionMenuModule, [{
        type: NgModule,
        args: [{
                declarations: [ActionMenuComponent],
                exports: [ActionMenuComponent],
                imports: [
                    CommonModule,
                    ModalModule,
                    ButtonModule,
                    AngularSvgIconModule,
                    ButtonGroupModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ActionMenuModule, { declarations: [ActionMenuComponent], imports: [CommonModule,
        ModalModule,
        ButtonModule,
        AngularSvgIconModule,
        ButtonGroupModule], exports: [ActionMenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class QuickFiltersService {
    constructor(systemConfigStore, screenSize, store) {
        this.systemConfigStore = systemConfigStore;
        this.screenSize = screenSize;
        this.store = store;
        this.quickFiltersConfigState = new BehaviorSubject({ buttons: [] });
        this.enabledState = new BehaviorSubject(false);
        this.screen = ScreenSize.Medium;
        this.defaultBreakpoint = 5;
        this.breakdownSizes = [];
        this.subs = [];
        this.config$ = this.quickFiltersConfigState.asObservable();
        this.enabled$ = this.enabledState.asObservable();
        this.enabled = false;
        this.breakdownSizes = this.systemConfigStore.getUi('quick_filters_breakdown_screen_sizes');
        const displayedQuickFilters = this.systemConfigStore.getUi('displayed_quick_filters');
        const quickFiltersBreakdownThresholds = this.systemConfigStore.getUi('quick_filters_breakdown_threshold');
        this.breakdown$ = this.screenSize.screenSize$.pipe(map(screenSize => {
            const quickFiltersBreakpoint = displayedQuickFilters[screenSize] ?? 2;
            const maxQuickFiltersForDisplay = quickFiltersBreakdownThresholds[screenSize] ?? 2;
            if (quickFiltersBreakpoint > maxQuickFiltersForDisplay) {
                return true;
            }
            return isTrue(this.breakdownSizes[screenSize] ?? false);
        }));
        this.subs.push(this.screenSize.screenSize$.subscribe(currentScreenSize => {
            if (currentScreenSize) {
                this.screen = currentScreenSize;
            }
            this.init();
        }));
    }
    init() {
        let filters = this.store.filterList.getFilters() ?? [];
        filters = filters.filter(filter => filter?.attributes?.quick_filter ?? false);
        this.enabled = this.areConfigEnabled();
        if (!filters || filters.length < 1) {
            this.enabled = false;
            this.enabledState.next(false);
            return;
        }
        this.enabledState.next(this.enabled);
        const config = {
            buttonKlass: ['settings-button btn btn-outline-main'],
            dropdownLabel: this.store.appStrings.LBL_QUICK_FILTERS || '',
            breakpoint: this.getBreakpoint(),
            showAfterBreakpoint: false,
            dropdownOptions: {
                placement: ['bottom-right'],
                wrapperKlass: ['dropdown-button-secondary', 'filter-action-group']
            },
            buttons: []
        };
        const activeFilters = this.store.activeFilters;
        let anyActive = false;
        filters.forEach((filter) => {
            const isQuickFilter = filter?.attributes?.quick_filter ?? false;
            if (!isQuickFilter) {
                return;
            }
            const isActive = Object.keys(activeFilters).some(key => key === filter.key);
            anyActive = anyActive || isActive;
            const button = {
                label: filter.attributes.name,
                title: filter.attributes.name,
                onClick: () => {
                    this.store.toggleQuickFilter(filter);
                }
            };
            if (isActive) {
                button.klass = ['active'];
            }
            config.buttons.push(button);
        });
        if (anyActive) {
            config.dropdownOptions.klass = ['active'];
            config.dropdownOptions.icon = 'filter';
        }
        this.quickFiltersConfigState.next(config);
    }
    destroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
        this.quickFiltersConfigState.unsubscribe();
    }
    getBreakpoint() {
        const breakpointMap = this.systemConfigStore.getUi('displayed_quick_filters');
        if (this.screen && breakpointMap && breakpointMap[this.screen]) {
            this.breakpoint = breakpointMap[this.screen];
            return this.breakpoint;
        }
        if (this.breakpoint) {
            return this.breakpoint;
        }
        return this.defaultBreakpoint;
    }
    areConfigEnabled() {
        const enableMap = this.systemConfigStore.getUi('enable_quick_filters');
        if (!this.screen || !enableMap) {
            return false;
        }
        return isTrue(enableMap[this.screen] ?? false);
    }
    static { this.ɵfac = function QuickFiltersService_Factory(t) { return new (t || QuickFiltersService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(ScreenSizeObserverService), i0.ɵɵinject(ListViewStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: QuickFiltersService, factory: QuickFiltersService.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QuickFiltersService, [{
        type: Injectable
    }], function () { return [{ type: SystemConfigStore }, { type: ScreenSizeObserverService }, { type: ListViewStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function SettingsMenuComponent_ng_container_1_div_1_scrm_button_group_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button-group", 10);
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("config$", ctx_r4.quickFilters.config$)("klass", "quick-filter-button");
} }
function SettingsMenuComponent_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5)(1, "div", 6);
    i0.ɵɵelement(2, "scrm-label", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 8);
    i0.ɵɵtemplate(4, SettingsMenuComponent_ng_container_1_div_1_scrm_button_group_4_Template, 1, 2, "scrm-button-group", 9);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", ctx_r3.quickFilters.config$);
} }
function SettingsMenuComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, SettingsMenuComponent_ng_container_1_div_1_Template, 5, 1, "div", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.showQuickFilters && ctx_r0.enableQuickFilters);
} }
function SettingsMenuComponent_scrm_button_group_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button-group", 11);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("config$", ctx_r1.config$);
} }
class SettingsMenuComponent {
    constructor(listStore, modalService, screenSize, systemConfigStore, quickFilters) {
        this.listStore = listStore;
        this.modalService = modalService;
        this.screenSize = screenSize;
        this.systemConfigStore = systemConfigStore;
        this.quickFilters = quickFilters;
        this.configState = new BehaviorSubject({ buttons: [] });
        this.config$ = this.configState.asObservable();
        this.showQuickFilters = true;
        this.enableQuickFilters = false;
        this.screen = ScreenSize.Medium;
        this.defaultBreakpoint = 5;
        this.subs = [];
    }
    ngOnInit() {
        this.configState.next(this.getButtonGroupConfig());
        const vm$ = this.listStore.widgets$.pipe(combineLatestWith(this.listStore.displayFilters$, this.listStore.criteria$, this.screenSize.screenSize$, this.listStore.showSidebarWidgets$, this.listStore.filterList.records$));
        this.subs.push(vm$.subscribe(([widgets, displayFilters, criteria, screenSize, showSidebarWidgets, savedFilters]) => {
            if (screenSize) {
                this.screen = screenSize;
            }
            this.configState.next(this.getButtonGroupConfig());
            this.quickFilters.init();
        }));
        this.subs.push(this.quickFilters.breakdown$.subscribe(breakdown => {
            this.showQuickFilters = !isTrue(breakdown);
        }));
        this.subs.push(this.quickFilters.enabled$.subscribe(enabled => {
            this.enableQuickFilters = isTrue(enabled ?? false);
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getButtonGroupConfig() {
        const availableButtons = [
            {
                show: () => this.checkFiltersDisplay(),
                button: this.getMyFiltersButton(),
            },
            {
                show: () => true,
                button: this.getFilterButton()
            },
            {
                show: () => this.listStore.widgets,
                button: this.getInsightsButton(),
            },
        ];
        const config = {
            buttonKlass: ['settings-button'],
            dropdownLabel: this.listStore.appStrings.LBL_OPTIONS || '',
            breakpoint: this.getBreakpoint(),
            dropdownOptions: {
                placement: ['bottom-right'],
                wrapperKlass: ['dropdown-button-secondary']
            },
            buttons: []
        };
        availableButtons.forEach(availableButton => {
            if (!availableButton.show) {
                config.buttons.push(availableButton.button);
                return;
            }
            if (availableButton.show()) {
                config.buttons.push(availableButton.button);
            }
        });
        return config;
    }
    checkFiltersDisplay() {
        const filters = this.listStore.filterList.getFilters() ?? [];
        const quickFilterBreakpoint = this.quickFilters.getBreakpoint();
        const totalFilters = filters.length;
        const totalQuickFilters = filters.filter(obj => obj.attributes.quick_filter).length;
        if (totalFilters > 0 && (totalQuickFilters > quickFilterBreakpoint || (totalFilters - totalQuickFilters) > 0)) {
            return true;
        }
        return false;
    }
    getFilters() {
        return this?.listStore?.recordList?.criteria?.filters ?? {};
    }
    getCurrentCriteria() {
        return this?.listStore?.recordList?.criteria ?? {};
    }
    hasActiveFilter() {
        const activeFilters = this.listStore.activeFilters;
        if (!activeFilters) {
            return false;
        }
        const filterKeys = Object.keys(activeFilters) ?? [];
        if (!filterKeys || !filterKeys.length) {
            return false;
        }
        if (filterKeys.length > 1) {
            return true;
        }
        const currentFilter = activeFilters[filterKeys[0]];
        return currentFilter.key && currentFilter.key !== '' && currentFilter.key !== 'default';
    }
    areAllCurrentCriteriaFilterEmpty() {
        return Object.keys(this.getFilters() ?? {}).every(key => this.getFilters()[key].operator === '');
    }
    isAnyFilterApplied() {
        return this.hasActiveFilter() || !this.areAllCurrentCriteriaFilterEmpty();
    }
    getBreakpoint() {
        const breakpointMap = this.systemConfigStore.getConfigValue('listview_settings_limits');
        if (this.screen && breakpointMap && breakpointMap[this.screen]) {
            this.breakpoint = breakpointMap[this.screen];
            return this.breakpoint;
        }
        if (this.breakpoint) {
            return this.breakpoint;
        }
        return this.defaultBreakpoint;
    }
    getFilterButton() {
        const groupedFilterButton = {
            type: 'grouped',
            items: []
        };
        const filterButton = {
            label: this.listStore.appStrings.LBL_FILTER || '',
            klass: {
                'filter-settings-button': true,
                'btn btn-sm settings-button': true,
                active: this.isAnyFilterApplied()
            },
            onClick: () => {
                this.listStore.showFilters = !this.listStore.showFilters;
            }
        };
        if (this.isAnyFilterApplied()) {
            filterButton.icon = 'filter';
        }
        groupedFilterButton.items.push(filterButton);
        if (this.isAnyFilterApplied()) {
            groupedFilterButton.items.push(this.getClearButton());
        }
        return groupedFilterButton;
    }
    getMyFiltersButton() {
        const filters = this.listStore.filterList.getFilters();
        const dropdownConfig = {
            label: this.listStore.appStrings.LBL_SAVED_FILTER_SHORTCUT || '',
            klass: ['dropdown-toggle'],
            wrapperKlass: ['filter-action-group'],
            items: [],
            sections: {
                'quick-filters': {
                    labelKey: 'LBL_QUICK_FILTERS'
                },
                'default': {
                    labelKey: 'LBL_SAVED_FILTER_SHORTCUT'
                },
            }
        };
        const activeFilters = this.listStore.activeFilters;
        let anyActive = false;
        let quickFilterCount = 0;
        const quickFilterBreakpoint = this.quickFilters.getBreakpoint();
        const isQuickFiltersEnabled = this.quickFilters.areConfigEnabled();
        filters.forEach((filter) => {
            const isQuickFilterButton = isTrue(filter?.attributes?.quick_filter ?? false);
            if (isQuickFiltersEnabled && isQuickFilterButton && quickFilterCount < quickFilterBreakpoint) {
                quickFilterCount++;
                return;
            }
            const isActive = Object.keys(activeFilters).some(key => key === filter.key);
            anyActive = anyActive || isActive;
            const button = {
                label: filter.attributes.name,
                title: filter.attributes.name,
                section: isQuickFilterButton ? 'quick-filters' : 'default',
                onClick: () => {
                    this.listStore.showFilters = false;
                    if (isActive) {
                        this.listStore.resetFilters();
                    }
                    else {
                        this.listStore.setOpenFilter(filter);
                        const selectedFilters = {};
                        selectedFilters[filter.key] = filter;
                        this.listStore.setFilters(selectedFilters);
                    }
                }
            };
            if (isActive) {
                button.icon = 'filter';
                button.iconKlass = 'small';
                button.klass = ['active'];
            }
            dropdownConfig.items.push(button);
        });
        if (anyActive) {
            dropdownConfig.klass = ['dropdown-toggle', 'active'];
        }
        return dropdownConfig;
    }
    getClearButton() {
        return {
            label: 'x',
            titleKey: 'LBL_CLEAR_FILTER',
            klass: {
                'btn btn-sm settings-button clear-filter-button btn-main-light': true
            },
            onClick: () => {
                this.listStore.showFilters = false;
                this.listStore.resetFilters();
            }
        };
    }
    getInsightsButton() {
        return {
            label: this.listStore.appStrings.LBL_INSIGHTS || '',
            klass: {
                active: this.listStore.showSidebarWidgets
            },
            icon: 'pie',
            onClick: () => {
                this.listStore.showSidebarWidgets = !this.listStore.showSidebarWidgets;
            }
        };
    }
    static { this.ɵfac = function SettingsMenuComponent_Factory(t) { return new (t || SettingsMenuComponent)(i0.ɵɵdirectiveInject(ListViewStore), i0.ɵɵdirectiveInject(i3$1.NgbModal), i0.ɵɵdirectiveInject(ScreenSizeObserverService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(QuickFiltersService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SettingsMenuComponent, selectors: [["scrm-settings-menu"]], decls: 5, vars: 4, consts: [[1, "list-view-settings", "w-100", "d-flex", "justify-content-end"], [4, "ngIf"], [1, "text-nowrap"], ["klass", "d-flex align-items-center", 3, "config$", 4, "ngIf"], ["class", "d-flex align-items-baseline", 4, "ngIf"], [1, "d-flex", "align-items-baseline"], [1, "text-nowrap", "text-muted", "fs-70", "pl-1", "mr-2"], ["labelKey", "LBL_QUICK_FILTERS"], [1, "quick-filter-border", "pr-xxl-1", "mr-xxl-1"], [3, "config$", "klass", 4, "ngIf"], [3, "config$", "klass"], ["klass", "d-flex align-items-center", 3, "config$"]], template: function SettingsMenuComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, SettingsMenuComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵelementStart(3, "div", 2);
            i0.ɵɵtemplate(4, SettingsMenuComponent_scrm_button_group_4_Template, 1, 1, "scrm-button-group", 3);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 2, ctx.quickFilters.config$));
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.config$);
        } }, dependencies: [i2.NgIf, ButtonGroupComponent, LabelComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SettingsMenuComponent, [{
        type: Component,
        args: [{ selector: 'scrm-settings-menu', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"list-view-settings w-100 d-flex justify-content-end\">\n    <ng-container *ngIf=\"(quickFilters.config$ | async) as vm\">\n        <div *ngIf=\"showQuickFilters && enableQuickFilters\"\n             class=\"d-flex align-items-baseline\">\n            <div class=\"text-nowrap text-muted fs-70 pl-1 mr-2\">\n                <scrm-label labelKey=\"LBL_QUICK_FILTERS\"></scrm-label>\n            </div>\n            <div class=\"quick-filter-border pr-xxl-1 mr-xxl-1\">\n                <scrm-button-group *ngIf=\"quickFilters.config$\" [config$]=\"quickFilters.config$\" [klass]=\"'quick-filter-button'\"></scrm-button-group>\n            </div>\n        </div>\n    </ng-container>\n    <div class=\"text-nowrap\">\n        <scrm-button-group *ngIf=\"config$\" [config$]=\"config$\" klass=\"d-flex align-items-center\"></scrm-button-group>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: ListViewStore }, { type: i3$1.NgbModal }, { type: ScreenSizeObserverService }, { type: SystemConfigStore }, { type: QuickFiltersService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SettingsMenuModule {
    static { this.ɵfac = function SettingsMenuModule_Factory(t) { return new (t || SettingsMenuModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SettingsMenuModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ColumnChooserModule,
            ImageModule,
            ButtonModule,
            DropdownButtonModule,
            NgbModule,
            ButtonGroupModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SettingsMenuModule, [{
        type: NgModule,
        args: [{
                declarations: [SettingsMenuComponent],
                exports: [SettingsMenuComponent],
                imports: [
                    CommonModule,
                    ColumnChooserModule,
                    ImageModule,
                    ButtonModule,
                    DropdownButtonModule,
                    NgbModule,
                    ButtonGroupModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SettingsMenuModule, { declarations: [SettingsMenuComponent], imports: [CommonModule,
        ColumnChooserModule,
        ImageModule,
        ButtonModule,
        DropdownButtonModule,
        NgbModule,
        ButtonGroupModule,
        LabelModule], exports: [SettingsMenuComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatusBarModule {
    static { this.ɵfac = function StatusBarModule_Factory(t) { return new (t || StatusBarModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: StatusBarModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModuleTitleModule,
            ActionMenuModule,
            SettingsMenuModule,
            AngularSvgIconModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatusBarModule, [{
        type: NgModule,
        args: [{
                declarations: [StatusBarComponent],
                exports: [StatusBarComponent],
                imports: [
                    CommonModule,
                    ModuleTitleModule,
                    ActionMenuModule,
                    SettingsMenuModule,
                    AngularSvgIconModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(StatusBarModule, { declarations: [StatusBarComponent], imports: [CommonModule,
        ModuleTitleModule,
        ActionMenuModule,
        SettingsMenuModule,
        AngularSvgIconModule], exports: [StatusBarComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function TableHeaderComponent_scrm_bulk_action_menu_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-bulk-action-menu", 7);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("selectionSource", ctx_r0.selection)("actionSource", ctx_r0.bulkActions);
} }
function TableHeaderComponent_scrm_pagination_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-pagination", 8);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("allowPagination", ctx_r1.isPaginationEnabled())("state", ctx_r1.pagination);
} }
class TableHeaderComponent {
    isPaginationEnabled() {
        return this.paginationType === 'pagination';
    }
    static { this.ɵfac = function TableHeaderComponent_Factory(t) { return new (t || TableHeaderComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableHeaderComponent, selectors: [["scrm-table-header"]], inputs: { selection: "selection", bulkActions: "bulkActions", pagination: "pagination", tableActions: "tableActions", paginationType: "paginationType" }, decls: 7, vars: 3, consts: [[1, "list-view-tableactions", "table-header"], [1, "d-flex", "justify-content-between", "align-items-center"], [1, "d-flex"], [3, "selectionSource", "actionSource", 4, "ngIf"], ["buttonClass", "btn table-action-button", 3, "config"], [1, "mx-0", "pl-0", "table-pagination-wrapper"], [3, "allowPagination", "state", 4, "ngIf"], [3, "selectionSource", "actionSource"], [3, "allowPagination", "state"]], template: function TableHeaderComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2);
            i0.ɵɵtemplate(3, TableHeaderComponent_scrm_bulk_action_menu_3_Template, 1, 2, "scrm-bulk-action-menu", 3);
            i0.ɵɵelement(4, "scrm-action-group-menu", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "div", 5);
            i0.ɵɵtemplate(6, TableHeaderComponent_scrm_pagination_6_Template, 1, 2, "scrm-pagination", 6);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.selection && ctx.bulkActions);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.tableActions);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.pagination);
        } }, dependencies: [i2.NgIf, PaginationComponent, BulkActionMenuComponent, ActionGroupMenuComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableHeaderComponent, [{
        type: Component,
        args: [{ selector: 'scrm-table-header', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start List View Table Header Section -->\n\n<div class=\"list-view-tableactions table-header\">\n    <div class=\"d-flex justify-content-between align-items-center\">\n        <div class=\"d-flex\">\n            <scrm-bulk-action-menu *ngIf=\"selection && bulkActions\"\n                                   [selectionSource]=\"selection\"\n                                   [actionSource]=\"bulkActions\">\n            </scrm-bulk-action-menu>\n            <scrm-action-group-menu [config]=\"tableActions\" buttonClass=\"btn table-action-button\"></scrm-action-group-menu>\n        </div>\n        <div class=\"mx-0 pl-0 table-pagination-wrapper\">\n            <scrm-pagination *ngIf=\"pagination\"\n                             [allowPagination]=\"isPaginationEnabled()\"\n                             [state]=\"pagination\">\n            </scrm-pagination>\n        </div>\n    </div>\n</div>\n\n<!-- End List View Table Header Section -->\n" }]
    }], null, { selection: [{
            type: Input
        }], bulkActions: [{
            type: Input
        }], pagination: [{
            type: Input
        }], tableActions: [{
            type: Input
        }], paginationType: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function TableBodyComponent_ng_container_0_ng_container_3_th_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "th", 13);
} }
function TableBodyComponent_ng_container_0_ng_container_3_td_2_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "td", 14)(1, "label", 15)(2, "input", 16);
    i0.ɵɵlistener("change", function TableBodyComponent_ng_container_0_ng_container_3_td_2_Template_input_change_2_listener() { const restoredCtx = i0.ɵɵrestoreView(_r15); const record_r13 = restoredCtx.$implicit; const ctx_r14 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r14.toggleSelection(record_r13["id"])); });
    i0.ɵɵelementEnd();
    i0.ɵɵelement(3, "span", 17);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const record_r13 = ctx.$implicit;
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    const ctx_r12 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("checked", record_r13["id"] && vm_r1.selected[record_r13["id"]] || ctx_r12.allSelected(vm_r1.selectionStatus))("disabled", ctx_r12.allSelected(vm_r1.selectionStatus));
} }
function TableBodyComponent_ng_container_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0, 12);
    i0.ɵɵtemplate(1, TableBodyComponent_ng_container_0_ng_container_3_th_1_Template, 1, 0, "th", 7);
    i0.ɵɵtemplate(2, TableBodyComponent_ng_container_0_ng_container_3_td_2_Template, 4, 2, "td", 8);
    i0.ɵɵelementContainerEnd();
} }
function TableBodyComponent_ng_container_0_ng_container_4_th_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "th", 21);
} }
function TableBodyComponent_ng_container_0_ng_container_4_td_2_scrm_record_details_popup_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-record-details-popup-button", 24);
} if (rf & 2) {
    const record_r19 = i0.ɵɵnextContext().$implicit;
    const ctx_r20 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("record", record_r19)("columns", ctx_r20.popoverColumns);
} }
function TableBodyComponent_ng_container_0_ng_container_4_td_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td", 22);
    i0.ɵɵtemplate(1, TableBodyComponent_ng_container_0_ng_container_4_td_2_scrm_record_details_popup_button_1_Template, 1, 2, "scrm-record-details-popup-button", 23);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r18 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r18.popoverColumns.length);
} }
function TableBodyComponent_ng_container_0_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0, 18);
    i0.ɵɵtemplate(1, TableBodyComponent_ng_container_0_ng_container_4_th_1_Template, 1, 0, "th", 19);
    i0.ɵɵtemplate(2, TableBodyComponent_ng_container_0_ng_container_4_td_2_Template, 2, 1, "td", 20);
    i0.ɵɵelementContainerEnd();
} }
function TableBodyComponent_ng_container_0_ng_container_5_th_1_scrm_sort_button_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-sort-button", 31);
} if (rf & 2) {
    const column_r22 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r25 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("state", ctx_r25.getFieldSort(column_r22));
} }
function TableBodyComponent_ng_container_0_ng_container_5_th_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "th", 28);
    i0.ɵɵelement(1, "scrm-label", 29);
    i0.ɵɵtemplate(2, TableBodyComponent_ng_container_0_ng_container_5_th_1_scrm_sort_button_2_Template, 1, 1, "scrm-sort-button", 30);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const column_r22 = i0.ɵɵnextContext().$implicit;
    const ctx_r23 = i0.ɵɵnextContext(2);
    let tmp_0_0;
    i0.ɵɵclassMap(((tmp_0_0 = "primary-table-header " + "column-" + (column_r22 == null ? null : column_r22.name)) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "") + " " + ((tmp_0_0 = "column-type-" + (column_r22 == null ? null : column_r22.type)) !== null && tmp_0_0 !== undefined ? tmp_0_0 : ""));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", column_r22.label)("module", ctx_r23.config.module || "");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r23.config.sort$ && column_r22.sortable);
} }
function TableBodyComponent_ng_container_0_ng_container_5_td_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td", 14);
    i0.ɵɵelement(1, "scrm-field", 32);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r28 = ctx.$implicit;
    const column_r22 = i0.ɵɵnextContext().$implicit;
    const ctx_r24 = i0.ɵɵnextContext(2);
    let tmp_0_0;
    i0.ɵɵclassMap(((tmp_0_0 = "column-" + (column_r22 == null ? null : column_r22.name)) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "") + " " + ((tmp_0_0 = "column-type-" + (column_r22 == null ? null : column_r22.type)) !== null && tmp_0_0 !== undefined ? tmp_0_0 : ""));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("mode", "list")("type", column_r22.type)("field", ctx_r24.getField(column_r22, record_r28))("record", record_r28);
} }
function TableBodyComponent_ng_container_0_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0, 25);
    i0.ɵɵtemplate(1, TableBodyComponent_ng_container_0_ng_container_5_th_1_Template, 3, 5, "th", 26);
    i0.ɵɵtemplate(2, TableBodyComponent_ng_container_0_ng_container_5_td_2_Template, 2, 6, "td", 27);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const column_r22 = ctx.$implicit;
    i0.ɵɵproperty("cdkColumnDef", column_r22.name);
} }
function TableBodyComponent_ng_container_0_th_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "th", 13);
} }
function TableBodyComponent_ng_container_0_td_8_scrm_line_action_menu_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-line-action-menu", 34);
} if (rf & 2) {
    const record_r30 = i0.ɵɵnextContext().$implicit;
    const ctx_r31 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config", ctx_r31.config.lineActions)("activeLineAction", ctx_r31.activeLineAction)("record", record_r30)("wrapperClass", "listview-actions")("klass", "icon-bar");
} }
function TableBodyComponent_ng_container_0_td_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td", 14);
    i0.ɵɵtemplate(1, TableBodyComponent_ng_container_0_td_8_scrm_line_action_menu_1_Template, 1, 5, "scrm-line-action-menu", 33);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r30 = ctx.$implicit;
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", record_r30 && ctx_r6.config.lineActions);
} }
function TableBodyComponent_ng_container_0_tr_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "tr", 35);
} }
function TableBodyComponent_ng_container_0_tr_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "tr", 36);
} }
function TableBodyComponent_ng_container_0_div_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "p", 37);
    i0.ɵɵelement(2, "scrm-label", 38);
    i0.ɵɵelementEnd()();
} }
function TableBodyComponent_ng_container_0_div_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "scrm-loading-spinner", 39);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵclassProp("m-5", !vm_r1.records || vm_r1.records.length === 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("overlay", true);
} }
function TableBodyComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 1)(2, "table", 2);
    i0.ɵɵtemplate(3, TableBodyComponent_ng_container_0_ng_container_3_Template, 3, 0, "ng-container", 3);
    i0.ɵɵtemplate(4, TableBodyComponent_ng_container_0_ng_container_4_Template, 3, 0, "ng-container", 4);
    i0.ɵɵtemplate(5, TableBodyComponent_ng_container_0_ng_container_5_Template, 3, 1, "ng-container", 5);
    i0.ɵɵelementContainerStart(6, 6);
    i0.ɵɵtemplate(7, TableBodyComponent_ng_container_0_th_7_Template, 1, 0, "th", 7);
    i0.ɵɵtemplate(8, TableBodyComponent_ng_container_0_td_8_Template, 2, 1, "td", 8);
    i0.ɵɵelementContainerEnd();
    i0.ɵɵtemplate(9, TableBodyComponent_ng_container_0_tr_9_Template, 1, 0, "tr", 9);
    i0.ɵɵtemplate(10, TableBodyComponent_ng_container_0_tr_10_Template, 1, 0, "tr", 10);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(11, TableBodyComponent_ng_container_0_div_11_Template, 3, 0, "div", 0);
    i0.ɵɵtemplate(12, TableBodyComponent_ng_container_0_div_12_Template, 2, 3, "div", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("dataSource", ctx_r0.config.dataSource)("trackBy", ctx_r0.trackRecord);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.selection);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.popoverColumns && ctx_r0.popoverColumns.length);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", vm_r1.columns);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("cdkHeaderRowDef", vm_r1.displayedColumns);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("cdkRowDefColumns", vm_r1.displayedColumns);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !vm_r1.loading && vm_r1.records.length === 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.loading);
} }
class TableBodyComponent {
    constructor(fieldManager, loadingBufferFactory) {
        this.fieldManager = fieldManager;
        this.loadingBufferFactory = loadingBufferFactory;
        this.activeAction = new BehaviorSubject('');
        this.activeAction$ = this.activeAction.asObservable();
        this.maxColumns = 4;
        this.subs = [];
        this.currentPage = 1;
        this.pageSize = 20;
        this.loadingBuffer = this.loadingBufferFactory.create('table_loading_display_delay');
    }
    ngOnInit() {
        const selection$ = this.config.selection$ || of(null).pipe(shareReplay(1));
        let loading$ = this.initLoading();
        this.activeLineAction = {
            activeAction$: this.activeAction$,
            getActiveAction: () => {
                return this.activeAction.getValue();
            },
            setActiveAction: (key) => {
                this.activeAction.next(key);
            },
            resetActiveAction: () => {
                this.activeAction.next('');
            }
        };
        this.subs.push(this.config.pagination.pagination$.subscribe(pagination => {
            this.pageSize = pagination.pageSize;
            this.currentPage = Math.ceil(pagination.pageLast / pagination.pageSize);
        }));
        this.vm$ = this.config.columns.pipe(combineLatestWith(selection$, this.config.maxColumns$, this.config.dataSource.connect(null), loading$), map(([columns, selection, maxColumns, records, loading]) => {
            const displayedColumns = [];
            this.maxColumns = maxColumns;
            const columnsDefs = this.buildDisplayColumns(columns);
            this.popoverColumns = this.buildHiddenColumns(columns, columnsDefs);
            if (selection) {
                displayedColumns.push('checkbox');
            }
            if (this.popoverColumns && this.popoverColumns.length) {
                displayedColumns.push('show-more');
            }
            displayedColumns.push(...columnsDefs);
            displayedColumns.push('line-actions');
            const selected = selection && selection.selected || {};
            const selectionStatus = selection && selection.status || SelectionStatus.NONE;
            records.forEach((record, index) => {
                if (!record.metadata) {
                    record.metadata = {};
                }
                record.metadata.queryParams = {
                    offset: (index + 1) + ((this.currentPage - 1) * this.pageSize)
                };
            });
            return {
                columns,
                selection,
                selected,
                selectionStatus,
                displayedColumns,
                records: records || [],
                loading
            };
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    toggleSelection(id) {
        this.config.toggleRecordSelection(id);
    }
    allSelected(status) {
        return status === SelectionStatus.ALL;
    }
    buildDisplayColumns(metaFields) {
        let i = 0;
        let hasLinkField = false;
        const displayedColumns = [];
        const fields = metaFields.filter(function (field) {
            return !field.hasOwnProperty('default')
                || (field.hasOwnProperty('default') && field.default === true);
        });
        while (i < this.maxColumns && i < fields.length) {
            displayedColumns.push(fields[i].name);
            hasLinkField = hasLinkField || fields[i].link;
            i++;
        }
        if (!hasLinkField && (this.maxColumns < fields.length)) {
            for (i = this.maxColumns; i < fields.length; i++) {
                if (fields[i].link) {
                    displayedColumns.splice(-1, 1);
                    displayedColumns.push(fields[i].name);
                    break;
                }
            }
        }
        return displayedColumns;
    }
    buildHiddenColumns(metaFields, displayedColumns) {
        const fields = metaFields.filter(function (field) {
            return !field.hasOwnProperty('default')
                || (field.hasOwnProperty('default') && field.default === true);
        });
        let missingFields = [];
        for (let i = 0; i < fields.length; i++) {
            if (displayedColumns.indexOf(fields[i].name) === -1) {
                missingFields.push(fields[i].name);
            }
        }
        let hiddenColumns = fields.filter(obj => missingFields.includes(obj.name));
        return hiddenColumns;
    }
    getFieldSort(field) {
        return {
            getSortDirection: () => this.config.sort$.pipe(map((sort) => {
                let direction = SortDirection.NONE;
                if (sort.orderBy === field.name) {
                    direction = sort.sortOrder;
                }
                return direction;
            })),
            changeSortDirection: (direction) => {
                this.config.updateSorting(field.name, direction);
            }
        };
    }
    getField(column, record) {
        if (!column || !record) {
            return null;
        }
        return this.fieldManager.addField(record, column);
    }
    initLoading() {
        let loading$ = of(false).pipe(shareReplay(1));
        if (this.config.loading$) {
            this.subs.push(this.config.loading$.subscribe(loading => {
                this.loadingBuffer.updateLoading(loading);
            }));
            loading$ = this.loadingBuffer.loading$;
        }
        return loading$;
    }
    trackRecord(index, item) {
        return item?.id ?? '';
    }
    static { this.ɵfac = function TableBodyComponent_Factory(t) { return new (t || TableBodyComponent)(i0.ɵɵdirectiveInject(FieldManager), i0.ɵɵdirectiveInject(LoadingBufferFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableBodyComponent, selectors: [["scrm-table-body"]], inputs: { config: "config" }, decls: 2, vars: 3, consts: [[4, "ngIf"], [1, "position-relative", "d-flex", "flex-column"], ["cdk-table", "", "aria-describedby", "table-body", 1, "list-view-table", "striped-table", "table", 3, "dataSource", "trackBy"], ["cdkColumnDef", "checkbox", 4, "ngIf"], ["cdkColumnDef", "show-more", 4, "ngIf"], [3, "cdkColumnDef", 4, "ngFor", "ngForOf"], ["cdkColumnDef", "line-actions"], ["cdk-header-cell", "", "scope", "col", "class", "primary-table-header", 4, "cdkHeaderCellDef"], ["cdk-cell", "", 4, "cdkCellDef"], ["cdk-header-row", "", 4, "cdkHeaderRowDef"], ["cdk-row", "", 4, "cdkRowDef", "cdkRowDefColumns"], [3, "m-5", 4, "ngIf"], ["cdkColumnDef", "checkbox"], ["cdk-header-cell", "", "scope", "col", 1, "primary-table-header"], ["cdk-cell", ""], [1, "checkbox-container"], ["type", "checkbox", "aria-hidden", "true", 3, "checked", "disabled", "change"], [1, "checkmark"], ["cdkColumnDef", "show-more"], ["cdk-header-cell", "", "scope", "col", "class", "primary-table-header show-more-column", 4, "cdkHeaderCellDef"], ["cdk-cell", "", "class", "show-more-column", 4, "cdkCellDef"], ["cdk-header-cell", "", "scope", "col", 1, "primary-table-header", "show-more-column"], ["cdk-cell", "", 1, "show-more-column"], [3, "record", "columns", 4, "ngIf"], [3, "record", "columns"], [3, "cdkColumnDef"], ["cdk-header-cell", "", "scope", "col", 3, "class", 4, "cdkHeaderCellDef"], ["cdk-cell", "", 3, "class", 4, "cdkCellDef"], ["cdk-header-cell", "", "scope", "col"], [3, "labelKey", "module"], [3, "state", 4, "ngIf"], [3, "state"], [3, "mode", "type", "field", "record"], [3, "config", "activeLineAction", "record", "wrapperClass", "klass", 4, "ngIf"], [3, "config", "activeLineAction", "record", "wrapperClass", "klass"], ["cdk-header-row", ""], ["cdk-row", ""], [1, "lead", "text-center", "pt-3"], ["labelKey", "MSG_LIST_VIEW_NO_RESULTS_BASIC"], [3, "overlay"]], template: function TableBodyComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, TableBodyComponent_ng_container_0_Template, 13, 9, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, i4$1.CdkTable, i4$1.CdkRowDef, i4$1.CdkCellDef, i4$1.CdkHeaderCellDef, i4$1.CdkColumnDef, i4$1.CdkCell, i4$1.CdkRow, i4$1.CdkHeaderCell, i4$1.CdkHeaderRow, i4$1.CdkHeaderRowDef, FieldComponent, SortButtonComponent, LineActionMenuComponent, LoadingSpinnerComponent, LabelComponent, RecordDetailsPopupButtonComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableBodyComponent, [{
        type: Component,
        args: [{ selector: 'scrm-table-body', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <div class=\"position-relative d-flex flex-column\">\n        <table cdk-table [dataSource]=\"config.dataSource\" [trackBy]=\"trackRecord\"\n               aria-describedby=\"table-body\"\n               class=\"list-view-table striped-table table\">\n\n            <ng-container cdkColumnDef=\"checkbox\" *ngIf=\"vm.selection\">\n\n                <th cdk-header-cell scope=\"col\" *cdkHeaderCellDef class=\"primary-table-header\"></th>\n\n                <td cdk-cell *cdkCellDef=\"let record\">\n                    <label class=\"checkbox-container\">\n                        <input type=\"checkbox\"\n                               [checked]=\"(record['id'] && vm.selected[record['id']]) || allSelected(vm.selectionStatus) \"\n                               (change)=\"toggleSelection(record['id'])\"\n                               [disabled]=\"allSelected(vm.selectionStatus)\"\n                               aria-hidden=\"true\">\n                        <span class=\"checkmark\"></span>\n                    </label>\n                </td>\n\n            </ng-container>\n\n            <ng-container cdkColumnDef=\"show-more\" *ngIf=\"popoverColumns && popoverColumns.length\">\n\n                <th cdk-header-cell scope=\"col\" *cdkHeaderCellDef class=\"primary-table-header show-more-column\"></th>\n\n                <td cdk-cell *cdkCellDef=\"let record\" class=\"show-more-column\">\n                    <scrm-record-details-popup-button [record]=\"record\" [columns]=\"popoverColumns\"\n                                                      *ngIf=\"popoverColumns.length\"></scrm-record-details-popup-button>\n                </td>\n\n            </ng-container>\n\n            <ng-container *ngFor=\"let column of vm.columns\" [cdkColumnDef]=\"column.name\">\n\n                <th cdk-header-cell\n                    *cdkHeaderCellDef\n                    scope=\"col\"\n                    [class]=\"('primary-table-header ' + 'column-' + column?.name ?? '') + ' ' + ('column-type-' + column?.type ?? '')\">\n\n                    <scrm-label [labelKey]=\"column.label\" [module]=\"config.module || ''\"></scrm-label>\n                    <scrm-sort-button *ngIf=\"config.sort$ && column.sortable\"\n                                      [state]=\"getFieldSort(column)\">\n                    </scrm-sort-button>\n\n                </th>\n\n                <td cdk-cell *cdkCellDef=\"let record\" [class]=\"('column-' + column?.name ?? '') + ' ' + ('column-type-' + column?.type ?? '')\">\n                    <scrm-field [mode]=\"'list'\"\n                                [type]=\"column.type\"\n                                [field]=\"getField(column, record)\"\n                                [record]=\"record\">\n                    </scrm-field>\n                </td>\n\n            </ng-container>\n\n            <ng-container cdkColumnDef=\"line-actions\">\n\n                <th cdk-header-cell scope=\"col\" *cdkHeaderCellDef class=\"primary-table-header\"></th>\n\n                <td cdk-cell *cdkCellDef=\"let record\">\n                    <scrm-line-action-menu *ngIf=\"record && config.lineActions\"\n                                           [config]=\"config.lineActions\"\n                                           [activeLineAction]=\"activeLineAction\"\n                                           [record]=\"record\"\n                                           [wrapperClass]=\"'listview-actions'\"\n                                           [klass]=\"'icon-bar'\">\n                    </scrm-line-action-menu>\n                </td>\n\n            </ng-container>\n\n            <tr cdk-header-row *cdkHeaderRowDef=\"vm.displayedColumns\"></tr>\n            <tr cdk-row *cdkRowDef=\"let row; columns: vm.displayedColumns;\"></tr>\n\n        </table>\n\n        <div *ngIf=\"!vm.loading && vm.records.length === 0\">\n            <p class=\"lead text-center pt-3\">\n                <scrm-label labelKey=\"MSG_LIST_VIEW_NO_RESULTS_BASIC\"></scrm-label>\n            </p>\n        </div>\n        <div *ngIf=\"vm.loading\" [class.m-5]=\"!vm.records || vm.records.length === 0\">\n            <scrm-loading-spinner [overlay]=\"true\"></scrm-loading-spinner>\n        </div>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: FieldManager }, { type: LoadingBufferFactory }]; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function TableFooterComponent_scrm_bulk_action_menu_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-bulk-action-menu", 8);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("selectionSource", ctx_r0.selection)("actionSource", ctx_r0.bulkActions);
} }
function TableFooterComponent_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "scrm-load-more", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("loadMoreButton", ctx_r1.getLoadMoreButton());
} }
function TableFooterComponent_scrm_pagination_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-pagination", 11);
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("allowPagination", ctx_r2.isPaginationEnabled())("state", ctx_r2.pagination);
} }
class TableFooterComponent {
    isPaginationEnabled() {
        return this.paginationType === 'pagination';
    }
    getLoadMoreButton() {
        return {
            klass: 'load-more',
            labelKey: 'LBL_LOAD_MORE',
            onClick: () => {
                this.config.loadMore();
            }
        };
    }
    allLoaded() {
        return this.config?.allLoaded();
    }
    static { this.ɵfac = function TableFooterComponent_Factory(t) { return new (t || TableFooterComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableFooterComponent, selectors: [["scrm-table-footer"]], inputs: { selection: "selection", bulkActions: "bulkActions", pagination: "pagination", tableActions: "tableActions", paginationType: "paginationType", config: "config" }, decls: 8, vars: 4, consts: [[1, "list-view-tableactions", "table-footer"], [1, "d-flex", "justify-content-between", "align-items-center"], [1, "d-flex"], [3, "selectionSource", "actionSource", 4, "ngIf"], ["buttonClass", "btn table-action-button", 3, "config"], ["class", "mx-0 pl-0 load-more-style", 4, "ngIf"], [1, "mx-0", "pl-0", "table-pagination-wrapper"], [3, "allowPagination", "state", 4, "ngIf"], [3, "selectionSource", "actionSource"], [1, "mx-0", "pl-0", "load-more-style"], [3, "loadMoreButton"], [3, "allowPagination", "state"]], template: function TableFooterComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2);
            i0.ɵɵtemplate(3, TableFooterComponent_scrm_bulk_action_menu_3_Template, 1, 2, "scrm-bulk-action-menu", 3);
            i0.ɵɵelement(4, "scrm-action-group-menu", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(5, TableFooterComponent_div_5_Template, 2, 1, "div", 5);
            i0.ɵɵelementStart(6, "div", 6);
            i0.ɵɵtemplate(7, TableFooterComponent_scrm_pagination_7_Template, 1, 2, "scrm-pagination", 7);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.selection && ctx.bulkActions);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.tableActions);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.isPaginationEnabled() && !ctx.allLoaded());
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.pagination);
        } }, dependencies: [i2.NgIf, PaginationComponent, BulkActionMenuComponent, LoadMoreComponent, ActionGroupMenuComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableFooterComponent, [{
        type: Component,
        args: [{ selector: 'scrm-table-footer', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start List View Table Footer Section -->\n\n<div class=\"list-view-tableactions table-footer\">\n  <div class=\"d-flex justify-content-between align-items-center\">\n      <div class=\"d-flex\">\n          <scrm-bulk-action-menu *ngIf=\"selection && bulkActions\"\n                                 [selectionSource]=\"selection\"\n                                 [actionSource]=\"bulkActions\">\n          </scrm-bulk-action-menu>\n          <scrm-action-group-menu [config]=\"tableActions\" buttonClass=\"btn table-action-button\"></scrm-action-group-menu>\n      </div>\n      <div *ngIf=\"!isPaginationEnabled() && !allLoaded()\"\n           class=\"mx-0 pl-0 load-more-style\">\n          <scrm-load-more\n              [loadMoreButton]=\"getLoadMoreButton()\">\n          </scrm-load-more>\n      </div>\n      <div class=\"mx-0 pl-0 table-pagination-wrapper\">\n          <scrm-pagination *ngIf=\"pagination\"\n                           [allowPagination]=\"isPaginationEnabled()\"\n                           [state]=\"pagination\">\n          </scrm-pagination>\n      </div>\n  </div>\n</div>\n\n<!-- End List View Table Footer Section -->\n" }]
    }], null, { selection: [{
            type: Input
        }], bulkActions: [{
            type: Input
        }], pagination: [{
            type: Input
        }], tableActions: [{
            type: Input
        }], paginationType: [{
            type: Input
        }], config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function TableComponent_scrm_table_header_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-table-header", 3);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("bulkActions", ctx_r0.config.bulkActions)("paginationType", ctx_r0.getPaginationType())("pagination", ctx_r0.config.pagination)("selection", ctx_r0.config.selection)("tableActions", ctx_r0.config == null ? null : ctx_r0.config.tableActions);
} }
function TableComponent_scrm_table_footer_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-table-footer", 4);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("bulkActions", ctx_r1.config.bulkActions)("paginationType", ctx_r1.getPaginationType())("pagination", ctx_r1.config.pagination)("selection", ctx_r1.config.selection)("tableActions", ctx_r1.config == null ? null : ctx_r1.config.tableActions)("config", ctx_r1.config);
} }
class TableComponent {
    getPaginationType() {
        if (!this.config?.loadMore) {
            return 'pagination';
        }
        if (this.config?.paginationType !== 'load-more') {
            return 'pagination';
        }
        return this.config.paginationType;
    }
    showHeader() {
        return this.config.showHeader;
    }
    showFooter() {
        return this.config.showFooter;
    }
    static { this.ɵfac = function TableComponent_Factory(t) { return new (t || TableComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableComponent, selectors: [["scrm-table"]], inputs: { config: "config" }, decls: 4, vars: 6, consts: [[3, "bulkActions", "paginationType", "pagination", "selection", "tableActions", 4, "ngIf"], [3, "config"], [3, "bulkActions", "paginationType", "pagination", "selection", "tableActions", "config", 4, "ngIf"], [3, "bulkActions", "paginationType", "pagination", "selection", "tableActions"], [3, "bulkActions", "paginationType", "pagination", "selection", "tableActions", "config"]], template: function TableComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div");
            i0.ɵɵtemplate(1, TableComponent_scrm_table_header_1_Template, 1, 5, "scrm-table-header", 0);
            i0.ɵɵelement(2, "scrm-table-body", 1);
            i0.ɵɵtemplate(3, TableComponent_scrm_table_footer_3_Template, 1, 6, "scrm-table-footer", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMap(ctx.config && ctx.config.klass || "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.showHeader());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.config);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.showFooter());
        } }, dependencies: [i2.NgIf, TableHeaderComponent, TableBodyComponent, TableFooterComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableComponent, [{
        type: Component,
        args: [{ selector: 'scrm-table', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"{{ (config && config.klass) || ''}}\">\n    <scrm-table-header *ngIf=\"showHeader()\"\n                       [bulkActions]=\"config.bulkActions\"\n                       [paginationType]=\"getPaginationType()\"\n                       [pagination]=\"config.pagination\"\n                       [selection]=\"config.selection\"\n                       [tableActions]=\"config?.tableActions\"\n    >\n    </scrm-table-header>\n\n\n    <scrm-table-body [config]=\"config\"></scrm-table-body>\n\n\n    <scrm-table-footer *ngIf=\"showFooter()\"\n                       [bulkActions]=\"config.bulkActions\"\n                       [paginationType]=\"getPaginationType()\"\n                       [pagination]=\"config.pagination\"\n                       [selection]=\"config.selection\"\n                       [tableActions]=\"config?.tableActions\"\n                       [config]=\"config\"\n    >\n    </scrm-table-footer>\n</div>\n\n" }]
    }], null, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableHeaderModule {
    static { this.ɵfac = function TableHeaderModule_Factory(t) { return new (t || TableHeaderModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TableHeaderModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            PaginationModule,
            BulkActionMenuModule,
            AngularSvgIconModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableHeaderModule, [{
        type: NgModule,
        args: [{
                declarations: [TableHeaderComponent],
                exports: [TableHeaderComponent],
                imports: [
                    CommonModule,
                    PaginationModule,
                    BulkActionMenuModule,
                    AngularSvgIconModule,
                    ActionGroupMenuModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TableHeaderModule, { declarations: [TableHeaderComponent], imports: [CommonModule,
        PaginationModule,
        BulkActionMenuModule,
        AngularSvgIconModule,
        ActionGroupMenuModule], exports: [TableHeaderComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableBodyModule {
    static { this.ɵfac = function TableBodyModule_Factory(t) { return new (t || TableBodyModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TableBodyModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AngularSvgIconModule,
            CdkTableModule,
            FieldModule,
            SortButtonModule,
            LineActionModule,
            LoadingSpinnerModule,
            LabelModule,
            RecordDetailsPopupButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableBodyModule, [{
        type: NgModule,
        args: [{
                declarations: [TableBodyComponent],
                exports: [TableBodyComponent],
                imports: [
                    CommonModule,
                    AngularSvgIconModule,
                    CdkTableModule,
                    FieldModule,
                    SortButtonModule,
                    LineActionModule,
                    LoadingSpinnerModule,
                    LabelModule,
                    RecordDetailsPopupButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TableBodyModule, { declarations: [TableBodyComponent], imports: [CommonModule,
        AngularSvgIconModule,
        CdkTableModule,
        FieldModule,
        SortButtonModule,
        LineActionModule,
        LoadingSpinnerModule,
        LabelModule,
        RecordDetailsPopupButtonModule], exports: [TableBodyComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableFooterModule {
    static { this.ɵfac = function TableFooterModule_Factory(t) { return new (t || TableFooterModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TableFooterModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            PaginationModule,
            BulkActionMenuModule,
            AngularSvgIconModule,
            LoadMoreModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableFooterModule, [{
        type: NgModule,
        args: [{
                declarations: [TableFooterComponent],
                exports: [TableFooterComponent],
                imports: [
                    CommonModule,
                    PaginationModule,
                    BulkActionMenuModule,
                    AngularSvgIconModule,
                    LoadMoreModule,
                    ActionGroupMenuModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TableFooterModule, { declarations: [TableFooterComponent], imports: [CommonModule,
        PaginationModule,
        BulkActionMenuModule,
        AngularSvgIconModule,
        LoadMoreModule,
        ActionGroupMenuModule], exports: [TableFooterComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableModule {
    static { this.ɵfac = function TableModule_Factory(t) { return new (t || TableModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TableModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            TableHeaderModule,
            TableBodyModule,
            TableFooterModule,
            AngularSvgIconModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableModule, [{
        type: NgModule,
        args: [{
                declarations: [TableComponent],
                exports: [TableComponent],
                imports: [
                    CommonModule,
                    TableHeaderModule,
                    TableBodyModule,
                    TableFooterModule,
                    AngularSvgIconModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TableModule, { declarations: [TableComponent], imports: [CommonModule,
        TableHeaderModule,
        TableBodyModule,
        TableFooterModule,
        AngularSvgIconModule], exports: [TableComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineActionActionHandler extends ActionHandler {
    checkRecordAccess(data, defaultAcls = []) {
        const record = data.record ?? {};
        const acls = record.acls ?? [];
        if (!acls || !acls.length) {
            return false;
        }
        const action = data.action ?? null;
        return this.checkAccess(action, acls, defaultAcls);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CreateRelatedLineAction extends LineActionActionHandler {
    constructor(moduleNameMapper, router) {
        super();
        this.moduleNameMapper = moduleNameMapper;
        this.router = router;
        this.key = 'create';
        this.modes = ['list'];
    }
    run(data, action = null) {
        const configs = action.params['create'] || {};
        const params = {};
        /* eslint-disable camelcase,@typescript-eslint/camelcase*/
        params.return_module = configs.legacyModuleName;
        params.return_action = configs.returnAction;
        params.return_id = data.record.id;
        /* eslint-enable camelcase,@typescript-eslint/camelcase */
        params[configs.mapping.moduleName] = configs.legacyModuleName;
        params[configs.mapping.name] = data.record.attributes.name;
        params[configs.mapping.id] = data.record.id;
        const route = '/' + configs.module + '/' + configs.action;
        this.router.navigate([route], {
            queryParams: params
        }).then();
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function CreateRelatedLineAction_Factory(t) { return new (t || CreateRelatedLineAction)(i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(i1$2.Router)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CreateRelatedLineAction, factory: CreateRelatedLineAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CreateRelatedLineAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ModuleNameMapper }, { type: i1$2.Router }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessLineAction extends LineActionActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        const defaultAcls = data?.action?.acl ?? [];
        if (!defaultAcls.length) {
            return true;
        }
        return this.checkRecordAccess(data, defaultAcls);
    }
    static { this.ɵfac = function AsyncProcessLineAction_Factory(t) { return new (t || AsyncProcessLineAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessLineAction, factory: AsyncProcessLineAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessLineAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineActionActionManager extends BaseActionManager {
    constructor(createRelated, async) {
        super();
        this.createRelated = createRelated;
        this.async = async;
        createRelated.modes.forEach(mode => this.actions[mode][createRelated.key] = createRelated);
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
    }
    static { this.ɵfac = function LineActionActionManager_Factory(t) { return new (t || LineActionActionManager)(i0.ɵɵinject(CreateRelatedLineAction), i0.ɵɵinject(AsyncProcessLineAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LineActionActionManager, factory: LineActionActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineActionActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: CreateRelatedLineAction }, { type: AsyncProcessLineAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseLineActionsAdapter extends BaseRecordActionsAdapter {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    buildActionData(action, context) {
        return {
            record: (context && context.record) || null,
            action: action
        };
    }
    static { this.ɵfac = function BaseLineActionsAdapter_Factory(t) { return new (t || BaseLineActionsAdapter)(i0.ɵɵinject(LineActionActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseLineActionsAdapter, factory: BaseLineActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseLineActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: LineActionActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

class FavoritesService {
    constructor(metadata, processService) {
        this.metadata = metadata;
        this.processService = processService;
    }
    /**
     * Public Api
     */
    /**
     * Build new favorite
     * @param module
     * @param id
     */
    build(module, id) {
        return deepClone({
            module: 'Favorite',
            type: 'Favorite',
            attributes: {
                parent_id: id,
                parent_type: module,
            },
        });
    }
    /**
     * Add favorite
     * @param module
     * @param favorite
     */
    add(module, favorite) {
        this.update(module, favorite, 'add');
    }
    /**
     * Add favorite
     * @param module
     * @param favorite
     */
    remove(module, favorite) {
        this.update(module, favorite, 'remove');
    }
    /**
     * Save favorite to backend
     * @param module
     * @param favorite
     * @param action
     */
    update(module, favorite, action) {
        const processType = 'update-favorite';
        const options = {
            favorite: favorite,
            action
        };
        setTimeout(() => {
            this.processService.submit(processType, options).pipe(take(1)).subscribe(result => {
                const savedFavorite = result?.data?.favorite ?? null;
                if (savedFavorite === null) {
                    this.removeFavoriteFromMetadata(module, favorite);
                    return;
                }
                this.addFavoriteToMetadata(savedFavorite, module);
            });
        }, 100);
    }
    /**
     *
     * @param savedFavorite
     * @param module
     * @private
     */
    addFavoriteToMetadata(savedFavorite, module) {
        const saved = {
            id: savedFavorite?.id ?? '',
            module: savedFavorite?.module ?? '',
            attributes: { ...(savedFavorite?.attributes ?? {}) },
        };
        const newItemId = savedFavorite?.attributes?.parent_id ?? '';
        const metadata = this.metadata.getModuleMeta(module);
        const current = metadata?.favorites ?? null;
        if (current) {
            let cleared = current.filter(item => ((item?.attributes?.parent_id ?? '') !== newItemId));
            cleared.unshift(saved);
            metadata.favorites = cleared;
        }
        this.metadata.setModuleMetadata(module, metadata);
    }
    /**
     * Remove favorite from metadata
     * @param module
     * @param favorite
     */
    removeFavoriteFromMetadata(module, favorite) {
        const metadata = this.metadata.getModuleMeta(module);
        const current = metadata?.favorites ?? null;
        const parentId = favorite?.attributes?.parent_id ?? null;
        if (!current || !current.length || !parentId) {
            return;
        }
        metadata.favorites = current.filter(item => ((item?.attributes?.parent_id ?? '') !== parentId));
        this.metadata.setModuleMetadata(module, metadata);
    }
    static { this.ɵfac = function FavoritesService_Factory(t) { return new (t || FavoritesService)(i0.ɵɵinject(MetadataStore), i0.ɵɵinject(ProcessService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FavoritesService, factory: FavoritesService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FavoritesService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: MetadataStore }, { type: ProcessService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ImmediateDebounce {
    constructor() {
        this.buffer = new Subject();
        this.buffer$ = this.buffer.asObservable();
        this.enabled = true;
        this.subs = [];
        this.debounceTime = 1000;
    }
    init(time = 1000) {
        this.debounceTime = time;
        this.subs.push(this.buffer$.pipe(debounceTime(this.debounceTime)).subscribe(() => {
            this.enabled = true;
        }));
    }
    destroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    debounce(callBack) {
        if (!callBack) {
            return;
        }
        if (!this.enabled) {
            return;
        }
        this.enabled = false;
        callBack();
        this.buffer.next(true);
    }
    static { this.ɵfac = function ImmediateDebounce_Factory(t) { return new (t || ImmediateDebounce)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ImmediateDebounce, factory: ImmediateDebounce.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ImmediateDebounce, [{
        type: Injectable
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function FavoriteToggleComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r0.addButton);
} }
function FavoriteToggleComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r1.removeButton);
} }
class FavoriteToggleComponent {
    constructor(handler) {
        this.handler = handler;
        this.favorite = false;
    }
    ngOnInit() {
        if (!this.record) {
            return;
        }
        this.debounceService = new ImmediateDebounce();
        this.debounceService.init();
        this.favorite = this?.record?.favorite ?? false;
        this.addButton = {
            klass: ['btn btn-sm btn-outline-light favorite-star favorite-off'],
            onClick: () => {
                this.debounceService.debounce(() => {
                    this.add();
                });
            },
            icon: 'star'
        };
        this.removeButton = {
            klass: ['btn btn-sm btn-outline-light favorite-star favorite-on'],
            onClick: () => {
                this.debounceService.debounce(() => {
                    this.remove();
                });
            },
            icon: 'star'
        };
    }
    ngOnDestroy() {
        this.debounceService.destroy();
    }
    add() {
        this.record.favorite = true;
        this.favorite = true;
        const favorite = this.handler.build(this.record.module, this.record.id);
        this.handler.add(this.record.module, favorite);
    }
    remove() {
        this.record.favorite = false;
        this.favorite = false;
        const favorite = this.handler.build(this.record.module, this.record.id);
        this.handler.remove(this.record.module, favorite);
    }
    static { this.ɵfac = function FavoriteToggleComponent_Factory(t) { return new (t || FavoriteToggleComponent)(i0.ɵɵdirectiveInject(FavoritesService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FavoriteToggleComponent, selectors: [["scrm-favorite-toggle"]], inputs: { record: "record" }, decls: 2, vars: 2, consts: [[4, "ngIf"], [3, "config"]], template: function FavoriteToggleComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, FavoriteToggleComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            i0.ɵɵtemplate(1, FavoriteToggleComponent_ng_container_1_Template, 2, 1, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !ctx.favorite);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.favorite);
        } }, dependencies: [i2.NgIf, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FavoriteToggleComponent, [{
        type: Component,
        args: [{ selector: 'scrm-favorite-toggle', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"!favorite\">\n    <scrm-button [config]=\"addButton\"></scrm-button>\n</ng-container>\n<ng-container *ngIf=\"favorite\">\n    <scrm-button [config]=\"removeButton\"></scrm-button>\n</ng-container>\n" }]
    }], function () { return [{ type: FavoritesService }]; }, { record: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FavoriteToggleModule {
    static { this.ɵfac = function FavoriteToggleModule_Factory(t) { return new (t || FavoriteToggleModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FavoriteToggleModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FavoriteToggleModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    FavoriteToggleComponent
                ],
                exports: [
                    FavoriteToggleComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FavoriteToggleModule, { declarations: [FavoriteToggleComponent], imports: [CommonModule,
        ButtonModule], exports: [FavoriteToggleComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterActionHandler extends ActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterSaveAction extends SavedFilterActionHandler {
    constructor(message) {
        super();
        this.message = message;
        this.key = 'save';
        this.modes = ['edit'];
    }
    run(data) {
        data.store.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                data.store.save().pipe(take(1)).subscribe(savedFilter => {
                    data.listFilterStore.config.addSavedFilter(data.store.recordStore.extractBaseRecord(savedFilter));
                    data.listFilterStore.applyFilter();
                    this.message.addSuccessMessageByKey('LBL_SAVED_FILTER_SAVED');
                });
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay() {
        return true;
    }
    static { this.ɵfac = function SavedFilterSaveAction_Factory(t) { return new (t || SavedFilterSaveAction)(i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterSaveAction, factory: SavedFilterSaveAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterSaveAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterDeleteAction extends SavedFilterActionHandler {
    constructor(message, asyncActionService) {
        super();
        this.message = message;
        this.asyncActionService = asyncActionService;
        this.key = 'delete';
        this.modes = ['edit', 'detail'];
    }
    run(data) {
        const actionName = `record-${this.key}`;
        const baseRecord = (data.store.getBaseRecord()) || {};
        if (!baseRecord.id) {
            this.message.addWarningMessageByKey('LBL_FILTER_ID_NOT_DEFINED');
            return;
        }
        this.message.removeMessages();
        const asyncData = {
            action: actionName,
            module: baseRecord.module,
            id: baseRecord.id,
        };
        this.asyncActionService.run(actionName, asyncData, 'noop').pipe(take(1)).subscribe(() => {
            data.listFilterStore.config.removeSavedFilter(baseRecord);
        });
    }
    shouldDisplay(data) {
        const store = data && data.store;
        const filter = (store && store.recordStore.getBaseRecord()) || {};
        return !!filter.id;
    }
    static { this.ɵfac = function SavedFilterDeleteAction_Factory(t) { return new (t || SavedFilterDeleteAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(AsyncActionService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterDeleteAction, factory: SavedFilterDeleteAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterDeleteAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: AsyncActionService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterActionManager extends BaseActionManager {
    constructor(save, deleteAction) {
        super();
        save.modes.forEach(mode => this.actions[mode][save.key] = save);
        deleteAction.modes.forEach(mode => this.actions[mode][deleteAction.key] = deleteAction);
    }
    static { this.ɵfac = function SavedFilterActionManager_Factory(t) { return new (t || SavedFilterActionManager)(i0.ɵɵinject(SavedFilterSaveAction), i0.ɵɵinject(SavedFilterDeleteAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterActionManager, factory: SavedFilterActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SavedFilterSaveAction }, { type: SavedFilterDeleteAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$5 = {
    id: '',
    type: '',
    module: '',
    attributes: {}
};
class SavedFilterRecordStore extends RecordStore {
    constructor(definitions$, metadata$, recordSaveGQL, recordFetchGQL, message, recordManager, recordMappers, fieldManager, language) {
        super(definitions$, metadata$, recordSaveGQL, recordFetchGQL, message, recordManager, recordMappers);
        this.definitions$ = definitions$;
        this.metadata$ = metadata$;
        this.recordSaveGQL = recordSaveGQL;
        this.recordFetchGQL = recordFetchGQL;
        this.message = message;
        this.recordManager = recordManager;
        this.recordMappers = recordMappers;
        this.fieldManager = fieldManager;
        this.language = language;
        this.internalState = deepClone(initialState$5);
        this.stagingState = deepClone(initialState$5);
        this.store = new BehaviorSubject(this.internalState);
        this.staging = new BehaviorSubject(this.stagingState);
        this.searchFields = {};
        this.listColumns = [];
        this.state$ = this.store.asObservable().pipe(tap(record => {
            this.updateStaging(record);
        }));
        this.staging$ = this.staging.asObservable();
    }
    /**
     * Get search fields metadata
     * @returns SearchMetaFieldMap
     */
    getSearchFields() {
        return this.searchFields;
    }
    /**
     * Set search fields metadata
     * @param {object} searchFields SearchMetaFieldMap
     */
    setSearchFields(searchFields) {
        this.searchFields = searchFields;
    }
    /**
     * Get list fields metadata
     * @returns SearchMetaFieldMap
     */
    getListColumns() {
        return this.listColumns;
    }
    /**
     * Set list fields metadata
     * @param {object} listColumns SearchMetaFieldMap
     */
    setListColumns(listColumns) {
        this.listColumns = listColumns;
    }
    /**
     * Get record
     *
     * @returns {object} Record
     */
    getBaseRecord() {
        if (!this.stagingState) {
            return null;
        }
        this.mapStagingFields();
        return deepClone({
            id: this.stagingState.id,
            type: this.stagingState.type,
            module: this.stagingState.module,
            key: this.stagingState.key,
            searchModule: this.stagingState.searchModule,
            criteria: this.stagingState.criteria,
            attributes: this.stagingState.attributes,
        });
    }
    /**
     * Extract base record
     *
     * @returns {object} Record
     */
    extractBaseRecord(record) {
        if (!record) {
            return null;
        }
        let criteria = record.criteria ?? {};
        if (Array.isArray(criteria) && !criteria.length) {
            criteria = {};
        }
        return deepClone({
            id: record.id,
            type: record.type,
            module: record.module,
            key: record.key,
            searchModule: record.searchModule,
            criteria: criteria,
            attributes: record.attributes,
        });
    }
    /**
     * Init record fields
     *
     * @param {object} record Record
     */
    initRecord(record) {
        if (this.metadata) {
            record.metadata = this.metadata;
        }
        if (!record?.validationTriggered) {
            record.validationTriggered = signal(false);
        }
        record.attributes = record.attributes || {};
        record.attributes.search_module = record.searchModule;
        const filters = record?.attributes?.contents?.filters ?? {};
        record.attributes.contents = record.attributes.contents || { filters: {} };
        if (Array.isArray(filters) && !filters.length) {
            record.attributes.contents.filters = {};
        }
        else {
            record.attributes.contents.filters = filters;
        }
        record.criteria = this.getCriteria(record);
        this.initCriteriaFields(record, this.getSearchFields());
        if (record.module && this.definitions && this.definitions.length > 0) {
            record.fields = this.recordManager.initFields(record, this.definitions);
        }
        this.initOrderByOptions(record);
    }
    /**
     * Init Order by options using list view columns set as default
     * @param record
     */
    initOrderByOptions(record) {
        if (!record.fields || !record.fields.orderBy) {
            return;
        }
        record.fields.orderBy.metadata = record.fields.orderBy.metadata || {};
        const options = [];
        this.getListColumns().forEach(column => {
            if (!column.default || column.default !== true) {
                return;
            }
            const labelKey = column.label || column.fieldDefinition.vname || '';
            const label = this.language.getFieldLabel(labelKey, record.searchModule);
            options.push({
                value: column.fieldDefinition.name || column.name,
                label
            });
        });
        record.fields.orderBy.metadata.options$ = of(options).pipe(shareReplay());
    }
    /**
     * Get criteria from filter
     * @param filter
     */
    getCriteria(filter) {
        if (!filter || !filter.criteria) {
            return { filters: {} };
        }
        if (!filter.criteria.filters) {
            return { ...filter.criteria, filters: {} };
        }
        if (Array.isArray(filter.criteria.filters) && !filter.criteria.filters.length) {
            return { ...filter.criteria, filters: {} };
        }
        return deepClone(filter.criteria);
    }
    /**
     * Initialize criteria fields
     *
     * @param {object} record to use
     * @param {object} searchFields to use
     */
    initCriteriaFields(record, searchFields) {
        record.criteriaFields = record.criteriaFields || {};
        if (!record.criteriaFormGroup) {
            record.criteriaFormGroup = new UntypedFormGroup({});
        }
        if (!searchFields) {
            return;
        }
        Object.keys(searchFields).forEach(key => {
            this.buildField(record, searchFields[key]);
        });
    }
    /**
     * Build filter field according to Field interface
     *
     * @param {object} record SavedFilter
     * @param {object} fieldMeta to use
     */
    buildField(record, fieldMeta) {
        const fieldName = fieldMeta.name;
        const type = fieldMeta.type;
        const definition = {
            name: fieldMeta.name,
            label: fieldMeta.label,
            vardefBased: fieldMeta?.vardefBased ?? false,
            readonly: fieldMeta?.readonly ?? false,
            display: fieldMeta?.display ?? '',
            type,
            fieldDefinition: {}
        };
        if (fieldMeta.fieldDefinition) {
            definition.fieldDefinition = fieldMeta.fieldDefinition;
        }
        if (type === 'bool' || type === 'boolean') {
            definition.fieldDefinition.options = 'dom_int_bool';
        }
        this.fieldManager.addFilterField(record, definition, this.language);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterRecordStoreFactory {
    constructor(recordFetchGQL, recordSaveGQL, message, recordManager, recordMappers, baseMapper, fieldManager, language) {
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.message = message;
        this.recordManager = recordManager;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        this.fieldManager = fieldManager;
        this.language = language;
        recordMappers.register('default', baseMapper.getKey(), baseMapper);
    }
    create(definitions$, metadata$) {
        return new SavedFilterRecordStore(definitions$, metadata$, this.recordSaveGQL, this.recordFetchGQL, this.message, this.recordManager, this.recordMappers, this.fieldManager, this.language);
    }
    static { this.ɵfac = function SavedFilterRecordStoreFactory_Factory(t) { return new (t || SavedFilterRecordStoreFactory)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordManager), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper), i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterRecordStoreFactory, factory: SavedFilterRecordStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterRecordStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: MessageService }, { type: RecordManager }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }, { type: FieldManager }, { type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$4 = {
    module: '',
    searchModule: '',
    recordID: '',
    loading: false,
    mode: 'detail',
};
class SavedFilterStore {
    constructor(appStateStore, meta, message, fieldManager, language, savedFilterStoreFactory) {
        this.appStateStore = appStateStore;
        this.meta = meta;
        this.message = message;
        this.fieldManager = fieldManager;
        this.language = language;
        this.savedFilterStoreFactory = savedFilterStoreFactory;
        /** Internal Properties */
        this.cache$ = null;
        this.internalState = deepClone(initialState$4);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subs = [];
        this.metadataLoadingState = new BehaviorSubject(false);
        this.metadataLoading$ = this.metadataLoadingState.asObservable();
        this.meta$ = this.meta.getMetadata('saved-search', ['recordView']).pipe(tap(() => this.metadataLoadingState.next(false)), map(definitions => {
            const recordViewMeta = { ...definitions.recordView };
            recordViewMeta.actions = (recordViewMeta?.actions ?? []).filter(value => {
                return value.key !== 'cancel';
            });
            return recordViewMeta;
        }));
        this.recordStore = savedFilterStoreFactory.create(this.getViewFields$(), this.getRecordMeta$());
        this.record$ = this.recordStore.state$.pipe(distinctUntilChanged(), map(record => record));
        this.stagingRecord$ = this.recordStore.staging$.pipe(distinctUntilChanged(), map(record => record));
        this.loading$ = this.state$.pipe(map(state => state.loading));
        this.mode$ = this.state$.pipe(map(state => state.mode));
        this.vm$ = this.stagingRecord$.pipe(combineLatestWith(this.mode$), map(([record, mode]) => {
            this.vm = { record, mode };
            return this.vm;
        }));
        this.recordValidationHandler = inject(RecordValidationHandler);
    }
    getModuleName() {
        return this.internalState.module;
    }
    getRecordId() {
        return this.internalState.recordID;
    }
    getViewContext() {
        return {
            module: this.getModuleName(),
            id: this.getRecordId(),
        };
    }
    /**
     * Clean destroy
     */
    destroy() {
        this.clear();
    }
    /**
     * Initial record load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} recordID to use
     * @param {string} mode to use
     * @returns {object} Observable<any>
     */
    init(recordID, mode = 'detail') {
        this.internalState.module = 'saved-search';
        this.internalState.recordID = recordID;
        this.setMode(mode);
        this.metadataLoadingState.next(true);
        const $data = forkJoin([this.meta$, this.load()]);
        return $data.pipe(map(([meta, record]) => record));
    }
    /**
     * Init record
     *
     * @param {string} searchModule name
     * @param {object} filter to use
     * @param {object} searchFields to use
     * @param {object} listColumns ColumnDefinition[]
     * @param {string} mode to use
     * @returns {object} Observable<any>
     */
    initRecord(searchModule, filter, searchFields, listColumns, mode = 'detail') {
        this.updateState({
            ...this.internalState,
            recordID: filter.id,
            module: 'saved-search',
            searchModule,
            mode
        });
        this.metadataLoadingState.next(true);
        this.meta$.pipe(take(1), tap(() => {
            this.metadataLoadingState.next(false);
            this.initStaging(searchModule, filter, searchFields, listColumns, null);
        })).subscribe();
    }
    initStaging(searchModule, filter, searchFields, listColumns, metadata) {
        const filterRecord = deepClone(this.recordStore.extractBaseRecord(filter));
        filterRecord.searchModule = searchModule;
        this.recordStore.setSearchFields(searchFields);
        this.recordStore.setListColumns(listColumns);
        this.recordStore.setMetadata(metadata);
        this.recordStore.setStaging(filterRecord);
        this.recordValidationHandler.initValidators(this.recordStore.getStaging());
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.cache$ = null;
        this.updateState(deepClone(initialState$4));
        this.metadataLoadingState.unsubscribe();
        this.metadataLoadingState = null;
        this.recordStore.destroy();
        this.recordStore = null;
    }
    /**
     * Clear observable cache
     */
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get staging record
     *
     * @returns {string} ViewMode
     */
    getBaseRecord() {
        return this.recordStore.getBaseRecord();
    }
    /**
     * Get current view mode
     *
     * @returns {string} ViewMode
     */
    getMode() {
        if (!this.internalState) {
            return null;
        }
        return this.internalState.mode;
    }
    /**
     * Set new mode
     *
     * @param {string} mode ViewMode
     */
    setMode(mode) {
        this.updateState({ ...this.internalState, mode });
    }
    /**
     * Save record
     */
    save() {
        this.appStateStore.updateLoading(`${this.internalState.module}-record-save`, true);
        return this.recordStore.save().pipe(catchError(() => {
            this.message.addDangerMessageByKey('LBL_ERROR_SAVING');
            return of({});
        }), finalize(() => {
            this.appStateStore.updateLoading(`${this.internalState.module}-record-save`, false);
        }));
    }
    /**
     * Validate search filter fields
     *
     * @returns {object} Observable<boolean>
     */
    validate() {
        return forkJoin([
            this.recordStore.validate(),
            this.validateCriteria()
        ]).pipe(map(([fields, criteria]) => fields && criteria));
    }
    /**
     * Validate search current input
     *
     * @returns {object} Observable<boolean>
     */
    validateCriteria() {
        const currentFilter = this.recordStore.getStaging();
        const formGroup = currentFilter.criteriaFormGroup;
        formGroup.markAllAsTouched();
        return formGroup.statusChanges.pipe(startWith(formGroup.status), filter(status => status !== 'PENDING'), take(1), map(status => status === 'VALID'));
    }
    /**
     * Load / reload record using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordViewState>
     */
    load(useCache = true) {
        this.appStateStore.updateLoading(`${this.internalState.module}-record-fetch`, true);
        return this.recordStore.retrieveRecord(this.internalState.module, this.internalState.recordID, useCache).pipe(tap((data) => {
            this.appStateStore.updateLoading(`${this.internalState.module}-record-fetch`, false);
            this.updateState({
                ...this.internalState,
                recordID: data.id,
                module: data.module,
            });
        }));
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<string[]>
     */
    getViewFieldsKeys$() {
        return this.meta$.pipe(map((recordMetadata) => {
            const fields = [];
            recordMetadata.panels.forEach(panel => {
                panel.rows.forEach(row => {
                    row.cols.forEach(col => {
                        fields.push(col.name);
                    });
                });
            });
            return fields;
        }));
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<ViewFieldDefinition[]>
     */
    getViewFields$() {
        return this.meta$.pipe(map((recordMetadata) => {
            const fields = [];
            recordMetadata.panels.forEach(panel => {
                panel.rows.forEach(row => {
                    row.cols.forEach(col => {
                        fields.push(col);
                    });
                });
            });
            return fields;
        }));
    }
    getRecordMeta$() {
        return this.meta$.pipe(map((recordMetadata) => {
            return recordMetadata.metadata || {};
        }));
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    /**
     * Get record view metadata
     *
     * @returns {object} metadata RecordViewMetadata
     */
    getMetadata() {
        const meta = this.meta.get() || {};
        return meta.recordView || {};
    }
    static { this.ɵfac = function SavedFilterStore_Factory(t) { return new (t || SavedFilterStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SavedFilterRecordStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterStore, factory: SavedFilterStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterStore, [{
        type: Injectable
    }], function () { return [{ type: AppStateStore }, { type: MetadataStore }, { type: MessageService }, { type: FieldManager }, { type: LanguageStore }, { type: SavedFilterRecordStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterSaveGQL extends RecordSaveGQL {
    constructor(apollo) {
        super(apollo);
        this.apollo = apollo;
    }
    save(record) {
        return super.save(record);
    }
    mapToRecord(response) {
        if (!response.data || !response.data.saveRecord || !response.data.saveRecord.record) {
            return null;
        }
        const savedFilter = {
            // eslint-disable-next-line no-underscore-dangle
            id: response.data.saveRecord.record._id,
            type: response.data.saveRecord.record.type || '',
            module: response.data.saveRecord.record.module || '',
            attributes: response.data.saveRecord.record.attributes || null,
        };
        savedFilter.key = savedFilter.id || (savedFilter.attributes && savedFilter.attributes.id) || '';
        const contents = (savedFilter.attributes && savedFilter.attributes.contents) || null;
        if (contents) {
            savedFilter.criteria = contents;
        }
        return savedFilter;
    }
    static { this.ɵfac = function SavedFilterSaveGQL_Factory(t) { return new (t || SavedFilterSaveGQL)(i0.ɵɵinject(i1.Apollo)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterSaveGQL, factory: SavedFilterSaveGQL.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterSaveGQL, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1.Apollo }]; }, null); })();

class SavedSearchRecordMapper {
    getKey() {
        return 'criteria';
    }
    map(record) {
        const savedFilter = record;
        if (savedFilter.criteria) {
            const contents = savedFilter?.attributes?.contents ?? {};
            const filters = savedFilter?.criteria?.filters ?? {};
            contents.filters = deepClone(filters);
            if (record.fields.name) {
                contents.name = record.fields.name.value;
                savedFilter.criteria.name = contents.name;
            }
            if (record.fields.orderBy) {
                contents.orderBy = record.fields.orderBy.value;
                savedFilter.criteria.orderBy = contents.orderBy;
            }
            if (record.fields.sortOrder) {
                contents.sortOrder = record.fields.sortOrder.value;
                savedFilter.criteria.sortOrder = contents.sortOrder;
            }
            if (record.attributes.search_module) {
                contents.searchModule = record.attributes.search_module;
                savedFilter.criteria.searchModule = contents.searchModule;
            }
            savedFilter.attributes.contents = contents;
        }
        let key = savedFilter.key || '';
        if (key === 'default') {
            key = '';
        }
        savedFilter.id = key;
        savedFilter.attributes.id = key;
    }
    static { this.ɵfac = function SavedSearchRecordMapper_Factory(t) { return new (t || SavedSearchRecordMapper)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedSearchRecordMapper, factory: SavedSearchRecordMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedSearchRecordMapper, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SaveFilterStoreFactory {
    constructor(recordFetchGQL, recordSaveGQL, appStateStore, languageStore, metadataStore, message, recordManager, fieldManager, recordMappers, baseMapper, savedSearchMapper) {
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.metadataStore = metadataStore;
        this.message = message;
        this.recordManager = recordManager;
        this.fieldManager = fieldManager;
        this.recordMappers = recordMappers;
        this.baseMapper = baseMapper;
        this.savedSearchMapper = savedSearchMapper;
        this.savedFilterStoreFactory = new SavedFilterRecordStoreFactory(recordFetchGQL, recordSaveGQL, message, recordManager, recordMappers, baseMapper, fieldManager, languageStore);
        this.recordMappers.register('saved-search', this.savedSearchMapper.getKey(), this.savedSearchMapper);
    }
    create() {
        return new SavedFilterStore(this.appStateStore, this.metadataStore, this.message, this.fieldManager, this.languageStore, this.savedFilterStoreFactory);
    }
    static { this.ɵfac = function SaveFilterStoreFactory_Factory(t) { return new (t || SaveFilterStoreFactory)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(SavedFilterSaveGQL), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordManager), i0.ɵɵinject(FieldManager), i0.ɵɵinject(i4.RecordMapperRegistry), i0.ɵɵinject(BaseSaveRecordMapper), i0.ɵɵinject(SavedSearchRecordMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SaveFilterStoreFactory, factory: SaveFilterStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SaveFilterStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordFetchGQL }, { type: SavedFilterSaveGQL }, { type: AppStateStore }, { type: LanguageStore }, { type: MetadataStore }, { type: MessageService }, { type: RecordManager }, { type: FieldManager }, { type: i4.RecordMapperRegistry }, { type: BaseSaveRecordMapper }, { type: SavedSearchRecordMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListFilterStore {
    constructor(message, savedFilterStoreFactory) {
        this.message = message;
        this.savedFilterStoreFactory = savedFilterStoreFactory;
        this.panelMode = 'closable';
        this.mode = 'filter';
        this.gridButtons = null;
        this.fields = [];
        this.special = [];
        this.savedFilters = [];
        this.subs = [];
        this.filterStore = savedFilterStoreFactory.create();
    }
    init(config) {
        this.config = config;
        this.initSearchFields();
        this.initConfigUpdatesSubscription();
        this.vm$ = this.filterStore.stagingRecord$.pipe(map(stagingRecord => [stagingRecord]), tap(([savedFilter]) => {
            this.reset();
            this.splitCriteriaFields(savedFilter);
            this.initDisplayFields();
            if (this.filterStore.getMode() !== 'detail') {
                this.initGridButtons();
            }
            this.initHeaderButtons();
            this.initMyFiltersButton(this.savedFilters);
        }));
        if (this.config.panelMode) {
            this.panelMode = this.config.panelMode;
        }
        this.collapse = new BehaviorSubject(false);
        this.isCollapsed$ = this.collapse.asObservable();
        if (!isVoid(this.config.isCollapsed)) {
            this.collapse.next(this.config.isCollapsed);
        }
        this.reset();
        this.initGridButtons();
        this.initHeaderButtons();
    }
    clear() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.reset();
        this.filterStore.clear();
        this.filterStore = null;
        this.collapse.unsubscribe();
    }
    clearAuthBased() {
        this.clear();
    }
    /**
     * Reset criteria
     */
    reset() {
        this.fields = [];
        this.special = [];
    }
    /**
     * Apply current filter values
     */
    applyFilter() {
        this.filterStore.validateCriteria().pipe(take(1)).subscribe(valid => {
            if (valid) {
                if (this.config.panelMode === 'collapsible' && this.config.collapseOnSearch) {
                    this.collapse.next(true);
                }
                this.config.onSearch();
                this.config.updateFilter(this.filterStore.getBaseRecord());
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    /**
     * Clear the current filter
     */
    clearFilter() {
        this.config.resetFilter(false);
    }
    /**
     * Subscribe to config updates.
     * Each time the filter or metadata changes we need to:
     * - Reset the view state
     * - Re-initialize the filter subscription
     */
    initConfigUpdatesSubscription() {
        this.subs.push(this.config.filter$.pipe(combineLatestWith(this.config.searchFields$), tap(([filter, searchFields]) => {
            this.reset();
            let mode = 'edit';
            const isReadOnly = filter.readonly ?? false;
            if (isReadOnly) {
                mode = 'detail';
                this.mode = mode;
            }
            this.filterStore.initRecord(this.config.module, filter, searchFields, this.config.listFields, mode);
        })).subscribe());
        this.subs.push(this.config.savedFilters$.pipe(map(value => [value]), tap(([filters]) => {
            this.savedFilters = filters;
            this.initMyFiltersButton(filters);
        })).subscribe());
    }
    /**
     * Split fields per slots
     *
     * @param {object} savedFilter to use
     */
    splitCriteriaFields(savedFilter) {
        if (!savedFilter || !savedFilter.criteriaFields) {
            return;
        }
        Object.entries(savedFilter.criteriaFields).forEach(([key, field]) => {
            const name = field.name || key;
            if (name.includes('_only')) {
                this.special.push(field);
                return;
            }
            if (!field.vardefBased) {
                this.fields.push(field);
                return;
            }
            if (field.readonly === true) {
                return;
            }
            const filters = savedFilter?.criteria?.filters ?? {};
            const fieldFilter = (filters[key] ?? {});
            if (!isEmpty(fieldFilter?.operator) && field.display === 'none') {
                field.display = 'default';
            }
            this.fields.push(field);
        });
    }
    initSearchFields() {
        this.subs.push(this.config.searchFields$.subscribe(searchFields => {
            this.searchFields = searchFields;
        }));
    }
    initDisplayFields() {
        if (!this.searchFields || emptyObject(this.searchFields) || !this.fields) {
            this.displayFields = [];
        }
        const fields = [];
        this.fields.forEach(field => {
            const name = field.name;
            if (field.display === 'none' || field.source === 'groupField') {
                return;
            }
            if (!this.searchFields[name]) {
                field.readonly = true;
            }
            fields.push(field);
        });
        this.displayFields = fields;
    }
    /**
     * Initialize grid buttons
     */
    initGridButtons() {
        this.gridButtons = [
            {
                id: 'clear',
                labelKey: 'LBL_CLEAR_BUTTON_LABEL',
                klass: ['clear-filters-button', 'btn', 'btn-outline-danger', 'btn-sm'],
                onClick: this.clearFilter.bind(this)
            },
            {
                id: 'search',
                labelKey: 'LBL_SEARCH_BUTTON_LABEL',
                klass: ['filter-button', 'btn', 'btn-danger', 'btn-sm'],
                onClick: this.applyFilter.bind(this)
            }
        ];
    }
    /**
     * Initialize header buttons
     */
    initHeaderButtons() {
        this.closeButton = {
            onClick: () => {
                this.config.onClose();
            }
        };
    }
    initMyFiltersButton(filters) {
        if (!filters || filters.length < 1) {
            this.myFilterButton = null;
            return;
        }
        const button = {
            wrapperKlass: ['filter-select'],
            labelKey: 'LBL_SAVED_FILTER_SHORTCUT',
            klass: ['btn', 'btn-outline-light', 'btn-sm'],
            items: [],
        };
        const currentKey = this.filterStore.getRecordId();
        filters.forEach(filter => {
            const item = {
                label: filter.attributes.name,
                onClick: () => {
                    this.config.setOpenFilter(filter);
                }
            };
            if (filter.key === currentKey) {
                button.label = filter.attributes.name;
                button.labelKey = '';
                item.icon = 'filter';
                item.iconKlass = 'small';
                item.klass = 'active';
            }
            button.items.push(item);
        });
        this.myFilterButton = button;
    }
    static { this.ɵfac = function ListFilterStore_Factory(t) { return new (t || ListFilterStore)(i0.ɵɵinject(MessageService), i0.ɵɵinject(SaveFilterStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListFilterStore, factory: ListFilterStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListFilterStore, [{
        type: Injectable
    }], function () { return [{ type: MessageService }, { type: SaveFilterStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, listFilterStore, language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.listFilterStore = listFilterStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.actions = {};
    }
    getActions(context) {
        return this.store.meta$.pipe(combineLatestWith(this.store.mode$, this.store.stagingRecord$, this.language.vm$), map(([meta, mode]) => {
            if (!mode || !meta) {
                return [];
            }
            const actions = this.parseModeActions(meta.actions, mode);
            actions.forEach((action) => {
                this.actions[action.key] = action;
            });
            return actions;
        }));
    }
    run(actionKey) {
        const action = this.actions[actionKey];
        if (!action) {
            return;
        }
        this.runAction(action);
    }
    buildActionData(action, context) {
        return {
            store: this.store,
            listFilterStore: this.listFilterStore,
            action
        };
    }
    getMode() {
        return this.store.getMode();
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, context) {
        this.store.load(false).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function SavedFilterActionsAdapter_Factory(t) { return new (t || SavedFilterActionsAdapter)(i0.ɵɵinject(SavedFilterStore), i0.ɵɵinject(ListFilterStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SavedFilterActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterActionsAdapter, factory: SavedFilterActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: SavedFilterStore }, { type: ListFilterStore }, { type: LanguageStore }, { type: SavedFilterActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SavedFilterActionAdapterFactory {
    constructor(language, actionManager, asyncActionService, message, confimation, selectModalService, metadata, appMetadataStore) {
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confimation = confimation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store, listFilterStore) {
        return new SavedFilterActionsAdapter(store, listFilterStore, this.language, this.actionManager, this.asyncActionService, this.message, this.confimation, this.selectModalService, this.metadata, this.appMetadataStore);
    }
    static { this.ɵfac = function SavedFilterActionAdapterFactory_Factory(t) { return new (t || SavedFilterActionAdapterFactory)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SavedFilterActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SavedFilterActionAdapterFactory, factory: SavedFilterActionAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SavedFilterActionAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LanguageStore }, { type: SavedFilterActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListFilterStoreFactory {
    constructor(message, savedFilterStoreFactory) {
        this.message = message;
        this.savedFilterStoreFactory = savedFilterStoreFactory;
    }
    create() {
        return new ListFilterStore(this.message, this.savedFilterStoreFactory);
    }
    static { this.ɵfac = function ListFilterStoreFactory_Factory(t) { return new (t || ListFilterStoreFactory)(i0.ɵɵinject(MessageService), i0.ɵɵinject(SaveFilterStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListFilterStoreFactory, factory: ListFilterStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListFilterStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: MessageService }, { type: SaveFilterStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ListFilterComponent_scrm_panel_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 6);
    i0.ɵɵelement(1, "scrm-dropdown-button", 7);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r2.store.myFilterButton);
} }
function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵelement(1, "input", 14);
    i0.ɵɵelementStart(2, "label", 15);
    i0.ɵɵelement(3, "scrm-label", 16);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const item_r8 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", item_r8.value);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", item_r8.labelKey);
} }
function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtemplate(1, ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_1_div_1_Template, 4, 2, "div", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r5.store.special);
} }
function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_2_scrm_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button", 7);
} if (rf & 2) {
    const button_r10 = ctx.$implicit;
    i0.ɵɵproperty("config", button_r10);
} }
function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 17);
    i0.ɵɵtemplate(1, ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_2_scrm_button_1_Template, 1, 1, "scrm-button", 18);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r6.store.gridButtons);
} }
function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "scrm-field-grid", 8);
    i0.ɵɵlistener("click", function ListFilterComponent_scrm_panel_0_scrm_field_grid_3_Template_scrm_field_grid_click_0_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r11.onFocusSearch()); });
    i0.ɵɵtemplate(1, ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_1_Template, 2, 1, "div", 9);
    i0.ɵɵtemplate(2, ListFilterComponent_scrm_panel_0_scrm_field_grid_3_div_2_Template, 2, 1, "div", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵproperty("actions", true)("appendActions", false)("fieldMode", ctx_r3.store.mode)("fields", ctx_r3.store.displayFields)("record", vm_r1)("special", ctx_r3.store.special.length > 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.store.special.length > 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.store.gridButtons);
} }
function ListFilterComponent_scrm_panel_0_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    const _r15 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 19);
    i0.ɵɵlistener("click", function ListFilterComponent_scrm_panel_0_ng_container_4_Template_div_click_1_listener() { i0.ɵɵrestoreView(_r15); const ctx_r14 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r14.onFocusSave()); });
    i0.ɵɵelement(2, "scrm-record-grid", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", ctx_r4.gridConfig);
} }
function ListFilterComponent_scrm_panel_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "scrm-panel", 1);
    i0.ɵɵtemplate(1, ListFilterComponent_scrm_panel_0_div_1_Template, 2, 1, "div", 2);
    i0.ɵɵelementStart(2, "div", 3);
    i0.ɵɵtemplate(3, ListFilterComponent_scrm_panel_0_scrm_field_grid_3_Template, 3, 8, "scrm-field-grid", 4);
    i0.ɵɵtemplate(4, ListFilterComponent_scrm_panel_0_ng_container_4_Template, 3, 1, "ng-container", 5);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵpropertyInterpolate1("klass", "filter-panel m-0 ", ctx_r0.config && ctx_r0.config.klass || "", "");
    i0.ɵɵproperty("showHeader", ctx_r0.config.displayHeader)("close", ctx_r0.store.closeButton)("isCollapsed$", ctx_r0.store.isCollapsed$)("mode", ctx_r0.store.panelMode)("titleKey", "LBL_BASIC_FILTER");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.store.myFilterButton);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.store.displayFields && ctx_r0.store.displayFields.length);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.config && ctx_r0.config.savedFilterEdit && ctx_r0.store.filterStore.getMode() !== "detail");
} }
class ListFilterComponent {
    onEnterKey() {
        if (!this.selectedActionButton) {
            return;
        }
        this.selectedActionButton.onClick();
        event.preventDefault();
    }
    constructor(storeFactory, actionAdapterFactory) {
        this.storeFactory = storeFactory;
        this.actionAdapterFactory = actionAdapterFactory;
        this.subs = [];
        this.store = storeFactory.create();
        this.filterActionsAdapter = actionAdapterFactory.create(this.store.filterStore, this.store);
    }
    ngOnInit() {
        this.store.init(this.config);
        this.vm$ = this.store.vm$.pipe(map(([savedFilter]) => {
            const record = { ...savedFilter };
            record.fields = savedFilter.criteriaFields;
            return record;
        }));
        this.searchActionButton = this.store.gridButtons.find(button => button.id === "search");
        this.saveActionButton = {
            id: 'save',
            onClick: () => {
                this.filterActionsAdapter.run('save');
            }
        };
        this.gridConfig = {
            record$: this.store.filterStore.stagingRecord$,
            mode$: this.store.filterStore.mode$,
            fields$: this.store.filterStore.getViewFieldsKeys$(),
            actions: this.filterActionsAdapter,
            appendActions: true,
            klass: 'mt-2 p-2 saved-search-container rounded',
            buttonClass: 'btn btn-outline-danger btn-sm',
            labelDisplay: 'inline',
            rowClass: {
                'align-items-start': true,
                'align-items-center': false
            },
            colAlignItems: 'align-items-start',
            maxColumns$: of(4).pipe(shareReplay(1)),
            sizeMap$: of({
                handset: 1,
                tablet: 2,
                web: 4,
                wide: 4
            }).pipe(shareReplay(1))
        };
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.store.clear();
        this.store = null;
    }
    onFocusSearch() {
        this.selectedActionButton = this.searchActionButton;
    }
    onFocusSave() {
        this.selectedActionButton = this.saveActionButton;
    }
    static { this.ɵfac = function ListFilterComponent_Factory(t) { return new (t || ListFilterComponent)(i0.ɵɵdirectiveInject(ListFilterStoreFactory), i0.ɵɵdirectiveInject(SavedFilterActionAdapterFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ListFilterComponent, selectors: [["scrm-list-filter"]], hostBindings: function ListFilterComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("keydown.enter", function ListFilterComponent_keydown_enter_HostBindingHandler($event) { return ctx.onEnterKey($event); });
        } }, inputs: { config: "config" }, decls: 2, vars: 3, consts: [[3, "showHeader", "close", "isCollapsed$", "mode", "klass", "titleKey", 4, "ngIf"], [3, "showHeader", "close", "isCollapsed$", "mode", "klass", "titleKey"], ["panel-header-button", "", 4, "ngIf"], ["panel-body", "", 1, "p-2", "filter-body"], [3, "actions", "appendActions", "fieldMode", "fields", "record", "special", "click", 4, "ngIf"], [4, "ngIf"], ["panel-header-button", ""], [3, "config"], [3, "actions", "appendActions", "fieldMode", "fields", "record", "special", "click"], ["class", "float-right mt-4", "field-grid-special", "", 4, "ngIf"], ["class", "mt-4 align-self-end", "field-grid-actions", "", 4, "ngIf"], ["field-grid-special", "", 1, "float-right", "mt-4"], ["class", "d-inline-block form-check mb-2 mr-sm-2", 4, "ngFor", "ngForOf"], [1, "d-inline-block", "form-check", "mb-2", "mr-sm-2"], ["type", "checkbox", 1, "form-check-input", 3, "value"], [1, "form-check-label"], [3, "labelKey"], ["field-grid-actions", "", 1, "mt-4", "align-self-end"], [3, "config", 4, "ngFor", "ngForOf"], [3, "click"]], template: function ListFilterComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ListFilterComponent_scrm_panel_0_Template, 5, 9, "scrm-panel", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, ButtonComponent, PanelComponent, FieldGridComponent, DropdownButtonComponent, LabelComponent, RecordGridComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListFilterComponent, [{
        type: Component,
        args: [{ selector: 'scrm-list-filter', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-panel *ngIf=\"(vm$ | async) as vm\"\n            [showHeader]=\"config.displayHeader\"\n            [close]=\"store.closeButton\"\n            [isCollapsed$]=\"store.isCollapsed$\"\n            [mode]=\"store.panelMode\"\n            klass=\"filter-panel m-0 {{ (config && config.klass) || ''}}\"\n            [titleKey]=\"'LBL_BASIC_FILTER'\"\n>\n\n    <div *ngIf=\"store.myFilterButton\" panel-header-button>\n        <scrm-dropdown-button [config]=\"store.myFilterButton\"></scrm-dropdown-button>\n    </div>\n\n    <div class=\"p-2 filter-body\" panel-body>\n\n        <scrm-field-grid *ngIf=\"store.displayFields && store.displayFields.length\"\n                         [actions]=\"true\"\n                         [appendActions]=\"false\"\n                         [fieldMode]=\"store.mode\"\n                         [fields]=\"store.displayFields\"\n                         [record]=\"vm\"\n                         [special]=\"store.special.length > 0\"\n                         (click)=\"onFocusSearch()\"\n        >\n\n            <div *ngIf=\"store.special.length > 0\" class=\"float-right mt-4\" field-grid-special>\n\n                <div *ngFor=\"let item of store.special \" class=\"d-inline-block form-check mb-2 mr-sm-2\">\n\n                    <input class=\"form-check-input\" type=\"checkbox\" [value]=\"item.value\">\n\n                    <label class=\"form-check-label\">\n                        <scrm-label [labelKey]=\"item.labelKey\"></scrm-label>\n                    </label>\n\n                </div>\n            </div>\n\n            <div *ngIf=\"store.gridButtons\" class=\"mt-4 align-self-end\" field-grid-actions>\n                <scrm-button *ngFor=\"let button of store.gridButtons\" [config]=\"button\"></scrm-button>\n            </div>\n        </scrm-field-grid>\n\n        <ng-container *ngIf=\"config && config.savedFilterEdit && store.filterStore.getMode() !== 'detail'\">\n            <div (click)=\"onFocusSave()\">\n                <scrm-record-grid [config]=\"gridConfig\"></scrm-record-grid>\n            </div>\n\n        </ng-container>\n    </div>\n\n</scrm-panel>\n" }]
    }], function () { return [{ type: ListFilterStoreFactory }, { type: SavedFilterActionAdapterFactory }]; }, { config: [{
            type: Input
        }], onEnterKey: [{
            type: HostListener,
            args: ['keydown.enter', ['$event']]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListFilterModule {
    static { this.ɵfac = function ListFilterModule_Factory(t) { return new (t || ListFilterModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ListFilterModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            PanelModule,
            FieldGridModule,
            DropdownButtonModule,
            LabelModule,
            RecordGridModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListFilterModule, [{
        type: NgModule,
        args: [{
                declarations: [ListFilterComponent],
                exports: [
                    ListFilterComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    PanelModule,
                    FieldGridModule,
                    DropdownButtonModule,
                    LabelModule,
                    RecordGridModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ListFilterModule, { declarations: [ListFilterComponent], imports: [CommonModule,
        ButtonModule,
        PanelModule,
        FieldGridModule,
        DropdownButtonModule,
        LabelModule,
        RecordGridModule,
        ButtonModule], exports: [ListFilterComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordListModalModule {
    static { this.ɵfac = function RecordListModalModule_Factory(t) { return new (t || RecordListModalModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordListModalModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModalModule,
            TableModule,
            LabelModule,
            LoadingSpinnerModule,
            ListFilterModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordListModalModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordListModalComponent],
                imports: [
                    CommonModule,
                    ModalModule,
                    TableModule,
                    LabelModule,
                    LoadingSpinnerModule,
                    ListFilterModule,
                    ButtonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordListModalModule, { declarations: [RecordListModalComponent], imports: [CommonModule,
        ModalModule,
        TableModule,
        LabelModule,
        LoadingSpinnerModule,
        ListFilterModule,
        ButtonModule] }); })();
i0.ɵɵsetComponentScope(RecordListModalComponent, [i2.NgIf, ModalComponent, TableComponent, LabelComponent, LoadingSpinnerComponent, ListFilterComponent, ButtonComponent], [i2.AsyncPipe]);

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordPanelComponent_scrm_panel_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-grid", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r2.getGridConfig());
} }
function RecordPanelComponent_scrm_panel_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "scrm-panel", 1)(1, "div", 2);
    i0.ɵɵtemplate(2, RecordPanelComponent_scrm_panel_0_ng_container_2_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵpropertyInterpolate1("klass", "record-panel ", ctx_r0.config && ctx_r0.config.klass || "", "");
    i0.ɵɵproperty("close", ctx_r0.closeButton)("isCollapsed$", ctx_r0.isCollapsed$)("mode", ctx_r0.panelMode)("titleKey", ctx_r0.config.title || "");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.config);
} }
class RecordPanelComponent {
    constructor() {
        this.panelMode = 'closable';
    }
    ngOnInit() {
        this.vm$ = this.config.store.vm$;
        this.initCloseButton();
        if (this.config.panelMode) {
            this.panelMode = this.config.panelMode;
        }
        this.collapse = new BehaviorSubject(false);
        this.isCollapsed$ = this.collapse.asObservable();
        if (!isVoid(this.config.isCollapsed)) {
            this.collapse.next(this.config.isCollapsed);
        }
    }
    ngOnDestroy() {
    }
    getGridConfig() {
        return {
            record$: this.config.store.stagingRecord$,
            mode$: this.config.store.mode$,
            fields$: this.config.store.getViewFieldsKeys$(),
            actions: this.config.actions,
            klass: 'mt-2 rounded',
            buttonClass: 'btn btn-outline-danger btn-sm',
            maxColumns$: of(4).pipe(shareReplay(1)),
            sizeMap$: of({
                handset: 1,
                tablet: 2,
                web: 3,
                wide: 4
            }).pipe(shareReplay(1)),
        };
    }
    /**
     * Init close button
     */
    initCloseButton() {
        this.closeButton = {
            onClick: () => {
                this.config.onClose();
            }
        };
    }
    static { this.ɵfac = function RecordPanelComponent_Factory(t) { return new (t || RecordPanelComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordPanelComponent, selectors: [["scrm-record-panel"]], inputs: { config: "config" }, decls: 2, vars: 3, consts: [[3, "close", "isCollapsed$", "mode", "titleKey", "klass", 4, "ngIf"], [3, "close", "isCollapsed$", "mode", "titleKey", "klass"], ["panel-body", "", 1, "pl-2", "pr-2"], [4, "ngIf"], [3, "config"]], template: function RecordPanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordPanelComponent_scrm_panel_0_Template, 3, 6, "scrm-panel", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, PanelComponent, RecordGridComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-panel', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-panel *ngIf=\"(vm$ | async) as vm\"\n            [close]=\"closeButton\"\n            [isCollapsed$]=\"isCollapsed$\"\n            [mode]=\"panelMode\"\n            [titleKey]=\"config.title || ''\"\n            klass=\"record-panel {{ (config && config.klass) || ''}}\">\n\n    <div class=\"pl-2 pr-2\" panel-body>\n\n        <ng-container *ngIf=\"config\">\n            <scrm-record-grid [config]=\"getGridConfig()\"></scrm-record-grid>\n        </ng-container>\n\n    </div>\n\n</scrm-panel>\n" }]
    }], function () { return []; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelActionHandler extends ActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelModule {
    static { this.ɵfac = function RecordPanelModule_Factory(t) { return new (t || RecordPanelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordPanelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ButtonModule,
            PanelModule,
            FieldGridModule,
            DropdownButtonModule,
            LabelModule,
            ButtonModule,
            RecordGridModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordPanelComponent],
                exports: [
                    RecordPanelComponent
                ],
                imports: [
                    CommonModule,
                    ButtonModule,
                    PanelModule,
                    FieldGridModule,
                    DropdownButtonModule,
                    LabelModule,
                    ButtonModule,
                    RecordGridModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordPanelModule, { declarations: [RecordPanelComponent], imports: [CommonModule,
        ButtonModule,
        PanelModule,
        FieldGridModule,
        DropdownButtonModule,
        LabelModule,
        ButtonModule,
        RecordGridModule], exports: [RecordPanelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelStore extends BaseRecordContainerStore {
    constructor(appStateStore, meta, message, fieldManager, language, storeFactory) {
        super(appStateStore, meta, message, fieldManager, language, storeFactory);
        this.appStateStore = appStateStore;
        this.meta = meta;
        this.message = message;
        this.fieldManager = fieldManager;
        this.language = language;
        this.storeFactory = storeFactory;
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<ViewFieldDefinition[]>
     */
    getViewFields$() {
        return this.meta$.pipe(map((meta) => {
            return meta.fields;
        }));
    }
    /**
     * Get view fields keys observable
     *
     * @returns {object} Observable<string[]>
     */
    getViewFieldsKeys$() {
        return this.meta$.pipe(map((meta) => {
            if (!meta.fields || !meta.fields.length) {
                return [];
            }
            const keys = [];
            meta.fields.forEach(field => {
                keys.push(field.name);
            });
            return keys;
        }));
    }
    /**
     * Init record
     *
     * @param {object} record to use
     * @param {string} mode to use
     * @param {boolean} loadMetadata to use
     * @returns {object} Observable<any>
     */
    initRecord(record, mode = 'detail', loadMetadata = true) {
        super.initRecord(record, mode, loadMetadata);
        this.setRecord(record);
    }
    static { this.ɵfac = function RecordPanelStore_Factory(t) { return new (t || RecordPanelStore)(i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(FieldManager), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPanelStore, factory: RecordPanelStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelStore, [{
        type: Injectable
    }], function () { return [{ type: AppStateStore }, { type: MetadataStore }, { type: MessageService }, { type: FieldManager }, { type: LanguageStore }, { type: RecordStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelStoreFactory {
    constructor(recordFetchGQL, recordSaveGQL, appStateStore, languageStore, metadataStore, message, recordManager, fieldManager, recordStoreFactory) {
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.metadataStore = metadataStore;
        this.message = message;
        this.recordManager = recordManager;
        this.fieldManager = fieldManager;
        this.recordStoreFactory = recordStoreFactory;
    }
    create() {
        return new RecordPanelStore(this.appStateStore, this.metadataStore, this.message, this.fieldManager, this.languageStore, this.recordStoreFactory);
    }
    static { this.ɵfac = function RecordPanelStoreFactory_Factory(t) { return new (t || RecordPanelStoreFactory)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordManager), i0.ɵɵinject(FieldManager), i0.ɵɵinject(RecordStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPanelStoreFactory, factory: RecordPanelStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: AppStateStore }, { type: LanguageStore }, { type: MetadataStore }, { type: MessageService }, { type: RecordManager }, { type: FieldManager }, { type: RecordStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$3 = {
    module: '',
    query: {},
    statistic: {
        id: '',
        data: {}
    },
    loading: false
};
class SeriesStatisticsStore extends StatisticsStore {
    constructor(fetchGQL) {
        super(fetchGQL);
        this.fetchGQL = fetchGQL;
        this.cache$ = null;
        this.internalState = deepClone(initialState$3);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.statistic$ = this.state$.pipe(map(state => state.statistic), distinctUntilChanged());
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        super.updateState(state);
    }
    static { this.ɵfac = function SeriesStatisticsStore_Factory(t) { return new (t || SeriesStatisticsStore)(i0.ɵɵinject(StatisticsFetchGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SeriesStatisticsStore, factory: SeriesStatisticsStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SeriesStatisticsStore, [{
        type: Injectable
    }], function () { return [{ type: StatisticsFetchGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SeriesTraverser {
    traverse(result, visitor, options) {
        if (result.singleSeries) {
            result.singleSeries.forEach(item => {
                visitor.visit(item, options);
            });
        }
        if (result.multiSeries) {
            result.multiSeries.forEach(series => {
                series.series.forEach(item => {
                    visitor.visit(item, options);
                });
            });
        }
    }
    static { this.ɵfac = function SeriesTraverser_Factory(t) { return new (t || SeriesTraverser)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SeriesTraverser, factory: SeriesTraverser.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SeriesTraverser, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CurrencyUnitConverter {
    constructor(currencyService, preferences) {
        this.currencyService = currencyService;
        this.preferences = preferences;
    }
    toUserFormat(value, options = null) {
        const numberValue = parseFloat(value);
        if (!isFinite(numberValue)) {
            return value;
        }
        const userCurrency = this.currencyService.getUserCurrency();
        return this.currencyService.baseToCurrency(userCurrency.id, numberValue).toString();
    }
    toInternalFormat(value) {
        const numberValue = parseFloat(value);
        if (!isFinite(numberValue)) {
            return value;
        }
        const userCurrency = this.currencyService.getUserCurrency();
        return this.currencyService.currencyToBase(userCurrency.id, numberValue).toString();
    }
    static { this.ɵfac = function CurrencyUnitConverter_Factory(t) { return new (t || CurrencyUnitConverter)(i0.ɵɵinject(CurrencyService), i0.ɵɵinject(UserPreferenceStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CurrencyUnitConverter, factory: CurrencyUnitConverter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CurrencyUnitConverter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: CurrencyService }, { type: UserPreferenceStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DataTypeUnitConverter {
    constructor(currencyUnitConverter) {
        this.currencyUnitConverter = currencyUnitConverter;
        this.map = {};
        this.addUnitConverter('currency', currencyUnitConverter);
    }
    addUnitConverter(unitType, unitConverter) {
        this.map[unitType] = unitConverter;
    }
    toUserFormat(dataType, value, options) {
        if (!dataType) {
            return value;
        }
        const formatter = this.map[dataType];
        if (!formatter) {
            return value;
        }
        return formatter.toUserFormat(value, options);
    }
    toInternalFormat(dataType, value) {
        if (!dataType) {
            return value;
        }
        const formatter = this.map[dataType];
        if (!formatter) {
            return value;
        }
        return formatter.toInternalFormat(value);
    }
    static { this.ɵfac = function DataTypeUnitConverter_Factory(t) { return new (t || DataTypeUnitConverter)(i0.ɵɵinject(CurrencyUnitConverter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DataTypeUnitConverter, factory: DataTypeUnitConverter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DataTypeUnitConverter, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: CurrencyUnitConverter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class DataTypeSeriesMapper {
    constructor(converter) {
        this.converter = converter;
    }
    visit(item, options) {
        const dataType = options?.dataType ?? null;
        const direction = options?.direction ?? 'user-unit';
        if (!dataType) {
            return;
        }
        const numberValue = parseFloat(item.value.toString());
        if (!isFinite(numberValue)) {
            return;
        }
        if (direction === 'user-unit') {
            item.value = this.converter.toUserFormat(dataType, numberValue.toString());
            return;
        }
        item.value = this.converter.toInternalFormat(dataType, numberValue.toString());
    }
    static { this.ɵfac = function DataTypeSeriesMapper_Factory(t) { return new (t || DataTypeSeriesMapper)(i0.ɵɵinject(DataTypeUnitConverter)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DataTypeSeriesMapper, factory: DataTypeSeriesMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DataTypeSeriesMapper, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: DataTypeUnitConverter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SeriesMapper {
    constructor(traverser, dataTypeMapper) {
        this.traverser = traverser;
        this.dataTypeMapper = dataTypeMapper;
        this.registry = {};
        this.addMapper('data-type-unit-converter', dataTypeMapper);
    }
    addMapper(unitType, mapper) {
        this.registry[unitType] = mapper;
    }
    map(result, mapperType, options) {
        const mapper = this?.registry[mapperType] ?? null;
        if (!mapper) {
            return;
        }
        this.traverser.traverse(result, mapper, options);
    }
    static { this.ɵfac = function SeriesMapper_Factory(t) { return new (t || SeriesMapper)(i0.ɵɵinject(SeriesTraverser), i0.ɵɵinject(DataTypeSeriesMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SeriesMapper, factory: SeriesMapper.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SeriesMapper, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SeriesTraverser }, { type: DataTypeSeriesMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$2 = {
    module: '',
    query: {},
    statistic: {
        id: '',
        data: {}
    },
    loading: false
};
class ChartDataStore extends SeriesStatisticsStore {
    constructor(fetchGQL, formatter, seriesMapper) {
        super(fetchGQL);
        this.fetchGQL = fetchGQL;
        this.formatter = formatter;
        this.seriesMapper = seriesMapper;
        this.internalState = deepClone(initialState$2);
        this.store = new BehaviorSubject(this.internalState);
        this.defaultOptions = {};
        this.state$ = this.store.asObservable();
        this.statistic$ = this.state$.pipe(map(state => state.statistic), distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading), distinctUntilChanged());
    }
    setDefaultOptions(chartOptions) {
        this.defaultOptions = chartOptions;
    }
    getDataSource() {
        return this.internalState.dataSource;
    }
    addNewState(statistic) {
        if (!statistic.metadata || !statistic.metadata.dataType) {
            return;
        }
        this.injectDefaultValues(statistic);
        const dataSource = this.buildCharDataSource(statistic);
        this.updateState({
            ...this.internalState,
            statistic,
            dataSource,
            loading: false
        });
    }
    injectDefaultValues(statistic) {
        if (!statistic.metadata.chartOptions) {
            statistic.metadata.chartOptions = deepClone(this.defaultOptions);
            return;
        }
        Object.keys(this.defaultOptions).forEach(optionKey => {
            if (!(optionKey in statistic.metadata.chartOptions)) {
                statistic.metadata.chartOptions[optionKey] = this.defaultOptions[optionKey];
            }
        });
    }
    buildCharDataSource(statistic) {
        const dataType = statistic.metadata.dataType || '';
        let formatOptions = null;
        const digits = (statistic.metadata && statistic.metadata.digits) || null;
        if (digits !== null) {
            formatOptions = {
                digits
            };
        }
        return {
            options: statistic.metadata.chartOptions || {},
            getResults: () => of(this.buildSeriesResult(statistic)).pipe(shareReplay(1)),
            tickFormatting: (value) => this.formatter.toUserFormat(dataType, value, formatOptions),
            tooltipFormatting: (value) => this.formatter.toUserFormat(dataType, value, formatOptions)
        };
    }
    buildSeriesResult(statistic) {
        const dataType = statistic.metadata.dataType || '';
        const result = {};
        const singleSeries = statistic.data.singleSeries || null;
        if (singleSeries) {
            result.singleSeries = singleSeries;
        }
        const multiSeries = statistic.data.multiSeries || null;
        if (multiSeries) {
            result.multiSeries = multiSeries;
        }
        this.seriesMapper.map(result, 'data-type-unit-converter', { dataType });
        return result;
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        super.updateState(state);
    }
    static { this.ɵfac = function ChartDataStore_Factory(t) { return new (t || ChartDataStore)(i0.ɵɵinject(StatisticsFetchGQL), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(SeriesMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ChartDataStore, factory: ChartDataStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartDataStore, [{
        type: Injectable
    }], function () { return [{ type: StatisticsFetchGQL }, { type: DataTypeFormatter }, { type: SeriesMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChartDataStoreFactory {
    constructor(fetchGQL, formatter, seriesMapper) {
        this.fetchGQL = fetchGQL;
        this.formatter = formatter;
        this.seriesMapper = seriesMapper;
    }
    create() {
        return new ChartDataStore(this.fetchGQL, this.formatter, this.seriesMapper);
    }
    static { this.ɵfac = function ChartDataStoreFactory_Factory(t) { return new (t || ChartDataStoreFactory)(i0.ɵɵinject(StatisticsFetchGQL), i0.ɵɵinject(DataTypeFormatter), i0.ɵɵinject(SeriesMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ChartDataStoreFactory, factory: ChartDataStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartDataStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: StatisticsFetchGQL }, { type: DataTypeFormatter }, { type: SeriesMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseWidgetComponent {
    static { this.ɵfac = function BaseWidgetComponent_Factory(t) { return new (t || BaseWidgetComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseWidgetComponent, selectors: [["ng-component"]], inputs: { config: "config", context: "context", context$: "context$" }, decls: 0, vars: 0, template: function BaseWidgetComponent_Template(rf, ctx) { }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseWidgetComponent, [{
        type: Component,
        args: [{ template: '' }]
    }], null, { config: [{
            type: Input,
            args: ['config']
        }], context: [{
            type: Input,
            args: ['context']
        }], context$: [{
            type: Input,
            args: ['context$']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_option_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 18);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const chart_r7 = ctx.$implicit;
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("value", ctx_r6.getKey(chart_r7));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r6.language.getFieldLabel(chart_r7.labelKey), " ");
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 13)(1, "div", 14)(2, "form", 15)(3, "select", 16);
    i0.ɵɵlistener("ngModelChange", function ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_Template_select_ngModelChange_3_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.onChartSelect()); })("ngModelChange", function ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_Template_select_ngModelChange_3_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r11 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r11.selectedChart = $event); });
    i0.ɵɵtemplate(4, ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_option_4_Template, 2, 2, "option", 17);
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngModel", ctx_r2.selectedChart);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2.configuredCharts);
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_ng_container_9_scrm_chart_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart", 20);
} if (rf & 2) {
    const ctx_r12 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("dataSource", ctx_r12.dataSource)("type", ctx_r12.chartType);
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_ng_container_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ChartSidebarWidgetComponent_scrm_widget_panel_0_ng_container_9_scrm_chart_1_Template, 1, 2, "scrm-chart", 19);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.dataSource && ctx_r3.chartType);
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21);
    i0.ɵɵelement(1, "scrm-loading-spinner", 22);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("m-5", !ctx_r4.dataSource);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("overlay", true);
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_p_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "p", 23);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r5.language.getFieldLabel(ctx_r5.messageLabelKey), " ");
} }
function ChartSidebarWidgetComponent_scrm_widget_panel_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "scrm-widget-panel", 1)(1, "div", 2)(2, "div", 3)(3, "div", 4)(4, "div", 5);
    i0.ɵɵtemplate(5, ChartSidebarWidgetComponent_scrm_widget_panel_0_div_5_Template, 5, 2, "div", 6);
    i0.ɵɵelementStart(6, "div", 7)(7, "div", 8)(8, "div", 9);
    i0.ɵɵtemplate(9, ChartSidebarWidgetComponent_scrm_widget_panel_0_ng_container_9_Template, 2, 1, "ng-container", 10);
    i0.ɵɵtemplate(10, ChartSidebarWidgetComponent_scrm_widget_panel_0_div_10_Template, 2, 3, "div", 11);
    i0.ɵɵtemplate(11, ChartSidebarWidgetComponent_scrm_widget_panel_0_p_11_Template, 2, 1, "p", 12);
    i0.ɵɵelementEnd()()()()()()()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("title", ctx_r0.title);
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r0.isConfigured && ctx_r0.chartOptions.toggle);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", ctx_r0.selectedChart && !ctx_r0.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.loading && (!ctx_r0.isConfigured() || !ctx_r0.dataSource));
} }
class ChartSidebarWidgetComponent extends BaseWidgetComponent {
    constructor(language, factory) {
        super();
        this.language = language;
        this.factory = factory;
        this.charts = {};
        this.titleLabelKey = 'LBL_INSIGHTS';
        this.title = '';
        this.messageLabelKey = 'LBL_CHART_NOT_FOUND';
        this.selectedChart = '';
        this.chartType = '';
        this.loading = true;
        this.subs = [];
    }
    ngOnInit() {
        this.appStrings$ = this.language.appStrings$;
        if (this.validateConfig() === false) {
            return;
        }
        if (this.context$) {
            this.subs.push(this.context$.subscribe((context) => {
                this.context = context;
                Object.keys(this.charts).forEach(key => {
                    const chart = this.charts[key];
                    chart.store.context = context;
                });
            }));
        }
        const options = this.config.options;
        const charts = options.charts;
        if (options.defaultChart) {
            this.selectedChart = options.defaultChart || '';
        }
        this.setupCharts(charts);
        this.setHeaderTitle(options);
        this.reloadSelectedChart();
        this.setupLoading();
        this.setupVM();
        this.setupReload();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    get configuredCharts() {
        return this.chartOptions.charts || [];
    }
    get chartOptions() {
        return this.config.options || {};
    }
    isConfigured() {
        return !!(this.config.options.charts && this.config.options.charts.length);
    }
    getLabelKey(stat) {
        const labelKey = stat.statistic.metadata && stat.statistic.metadata.labelKey;
        if (labelKey) {
            return labelKey;
        }
        return this.charts[stat.query.key].labelKey;
    }
    getKey(chart) {
        return chart.chartKey || chart.statisticsType || '';
    }
    validateConfig() {
        if (!this.context || !this.context.module) {
            this.messageLabelKey = 'LBL_BAD_CONFIG_BAD_CONTEXT';
            return false;
        }
        if (!this.config) {
            this.messageLabelKey = 'LBL_BAD_CONFIG_NO_CONFIG';
            return false;
        }
        const options = this.config.options;
        if (!options || !options.charts || !options.charts.length) {
            this.messageLabelKey = 'LBL_BAD_CONFIG_NO_STATISTICS_KEY';
            return false;
        }
        return true;
    }
    setupCharts(charts) {
        this.selectedChart = '';
        charts.forEach((chart) => {
            const key = this.getKey(chart);
            if (!key) {
                return;
            }
            if (!this.selectedChart) {
                this.selectedChart = key || '';
                this.chartType = chart.chartType;
            }
            this.buildChartInfo(key, chart);
            this.initChartStore(key, chart);
        });
    }
    buildChartInfo(key, chart) {
        this.charts[key] = {
            key,
            labelKey: chart.labelKey || '',
            chartType: chart.chartType,
            statisticsType: chart.statisticsType,
            store: this.factory.create(),
            reload: true
        };
    }
    initChartStore(key, chart) {
        this.charts[key].store.init(this.context.module, {
            key: chart.statisticsType,
            context: { ...this.context }
        }, false);
        this.charts[key].store.setDefaultOptions(chart.chartOptions);
    }
    setHeaderTitle(options) {
        if (this.config.labelKey) {
            this.titleLabelKey = this.config.labelKey;
        }
        if (options.headerTitle) {
            if (!this.charts || !this.charts[this.selectedChart] || !this.charts[this.selectedChart].labelKey) {
                return;
            }
            this.titleLabelKey = this.charts[this.selectedChart].labelKey;
        }
        this.title = this.language.getFieldLabel(this.titleLabelKey);
    }
    onChartSelect() {
        this.dataSource = null;
        this.chartType = this.charts[this.selectedChart].chartType;
        this.reloadSelectedChart(false);
    }
    setupVM() {
        const statistics$ = [];
        Object.keys(this.charts).forEach(key => statistics$.push(this.charts[key].store.state$));
        let statisticObs = of([]);
        if (statistics$.length < 1) {
            statisticObs = of([]);
        }
        else if (statistics$.length === 1) {
            statisticObs = statistics$[0].pipe(map(value => [value]));
        }
        else {
            let firsObs = null;
            let others;
            [firsObs, ...others] = statistics$;
            statisticObs = firsObs.pipe(combineLatestWith(others));
        }
        this.vm$ = statisticObs.pipe(combineLatestWith(this.language.appStrings$), map(([statistics, appStrings]) => {
            const statsMap = this.mapChartData(statistics);
            return {
                statistics: statsMap,
                appStrings
            };
        }));
    }
    mapChartData(statistics) {
        const statsMap = {};
        statistics.forEach((statistic) => {
            if (!statistic.query.key) {
                return;
            }
            statsMap[statistic.query.key] = statistic;
            this.charts[statistic.query.key].labelKey = this.getLabelKey(statistic);
        });
        return statsMap;
    }
    setupReload() {
        if (!this.config.reload$) {
            return;
        }
        this.subs.push(this.config.reload$.subscribe(() => {
            if (this.loading === true) {
                return;
            }
            this.loading = true;
            Object.keys(this.charts).forEach(chartKey => {
                this.charts[chartKey].reload = true;
            });
            this.reloadSelectedChart();
        }));
    }
    setupLoading() {
        const loadings$ = [];
        Object.keys(this.charts).forEach(key => loadings$.push(this.charts[key].store.loading$));
        let statisticObs = of([]);
        if (loadings$.length < 1) {
            statisticObs = of([]);
        }
        else if (loadings$.length === 1) {
            statisticObs = loadings$[0].pipe(map(value => [value]));
        }
        else {
            let firsObs = null;
            let others;
            [firsObs, ...others] = loadings$;
            statisticObs = firsObs.pipe(combineLatestWith(others));
        }
        this.loading$ = statisticObs.pipe(map((loadings) => {
            if (!loadings || loadings.length < 1) {
                this.loading = false;
                return false;
            }
            let loading = false;
            loadings.forEach(value => {
                loading = loading || value;
            });
            this.loading = loading;
            return loading;
        }));
        this.subs.push(this.loading$.subscribe());
    }
    reloadSelectedChart(useCache = false) {
        if (!this.charts || !this.charts[this.selectedChart] || !this.charts[this.selectedChart].store) {
            return;
        }
        useCache = useCache && !this.charts[this.selectedChart].reload;
        this.charts[this.selectedChart].store.load(useCache).pipe(take(1), tap(() => {
            this.dataSource = this.charts[this.selectedChart]?.store?.getDataSource() ?? null;
            this.charts[this.selectedChart].reload = false;
        })).subscribe();
    }
    static { this.ɵfac = function ChartSidebarWidgetComponent_Factory(t) { return new (t || ChartSidebarWidgetComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ChartDataStoreFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ChartSidebarWidgetComponent, selectors: [["chart-sidebar-widget"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [[3, "title", 4, "ngIf"], [3, "title"], ["widget-body", ""], [1, "widget-background", "chart-sidebar-widget"], [1, "mb-2", "ml-1", "mr-1"], [1, "container-fluid"], ["class", "row", 4, "ngIf"], [1, "row", "mt-3", "chart-widget"], [1, "col", "pl-0", "pr-0", "pb-1", "pt-1", "d-flex", "justify-content-center"], [1, "flex-grow-1"], [4, "ngIf"], ["class", "chart-loading", 3, "m-5", 4, "ngIf"], ["class", "lead text-center pt-3", 4, "ngIf"], [1, "row"], [1, "col", "pr-2", "pl-2"], [1, "login-form", "mb-0", "mt-2", "w-100"], ["name", "chart", 1, "m-0", "w-100", 3, "ngModel", "ngModelChange"], [3, "value", 4, "ngFor", "ngForOf"], [3, "value"], [3, "dataSource", "type", 4, "ngIf"], [3, "dataSource", "type"], [1, "chart-loading"], [3, "overlay"], [1, "lead", "text-center", "pt-3"]], template: function ChartSidebarWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ChartSidebarWidgetComponent_scrm_widget_panel_0_Template, 12, 5, "scrm-widget-panel", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, WidgetPanelComponent, i5$1.ɵNgNoValidate, i5$1.NgSelectOption, i5$1.ɵNgSelectMultipleOption, i5$1.SelectControlValueAccessor, i5$1.NgControlStatus, i5$1.NgControlStatusGroup, i5$1.NgModel, i5$1.NgForm, ChartComponent, LoadingSpinnerComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartSidebarWidgetComponent, [{
        type: Component,
        args: [{ selector: 'chart-sidebar-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-widget-panel [title]=\"this.title\" *ngIf=\"(vm$ | async) as vm\">\n    <div widget-body>\n        <div class=\"widget-background chart-sidebar-widget\">\n            <div class=\"mb-2 ml-1 mr-1\">\n                <div class=\"container-fluid\">\n                    <div class=\"row\" *ngIf=\"isConfigured && chartOptions.toggle\">\n                        <div class=\"col pr-2 pl-2\">\n                            <form class=\"login-form mb-0 mt-2 w-100\">\n\n                                <select (ngModelChange)=\"onChartSelect()\" [(ngModel)]=\"selectedChart\" class=\"m-0 w-100\"\n                                        name=\"chart\">\n                                    <option *ngFor=\"let chart of configuredCharts; index as i\"\n                                            [value]=\"getKey(chart)\">\n                                        {{language.getFieldLabel(chart.labelKey)}}\n                                    </option>\n                                </select>\n                            </form>\n                        </div>\n                    </div>\n\n                    <div class=\"row mt-3 chart-widget\">\n                        <div class=\"col pl-0 pr-0 pb-1 pt-1 d-flex justify-content-center\">\n                            <div class=\"flex-grow-1\">\n                                <ng-container *ngIf=\"selectedChart && !loading\">\n                                    <scrm-chart *ngIf=\"dataSource && chartType\"\n                                                [dataSource]=\"dataSource\"\n                                                [type]=\"chartType\">\n                                    </scrm-chart>\n                                </ng-container>\n                                <div *ngIf=\"loading\" [class.m-5]=\"!dataSource\" class=\"chart-loading\">\n                                    <scrm-loading-spinner [overlay]=\"true\"></scrm-loading-spinner>\n                                </div>\n                                <p *ngIf=\"!loading && (!isConfigured() || !dataSource)\"\n                                   class=\"lead text-center pt-3\">\n                                    {{language.getFieldLabel(this.messageLabelKey)}}\n                                </p>\n                            </div>\n                        </div>\n                    </div>\n                </div>\n            </div>\n        </div>\n    </div>\n</scrm-widget-panel>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: ChartDataStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ChartSidebarWidgetModule {
    static { this.ɵfac = function ChartSidebarWidgetModule_Factory(t) { return new (t || ChartSidebarWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ChartSidebarWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            WidgetPanelModule,
            FormsModule,
            ChartModule,
            LoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ChartSidebarWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [ChartSidebarWidgetComponent],
                exports: [ChartSidebarWidgetComponent],
                imports: [
                    CommonModule,
                    WidgetPanelModule,
                    FormsModule,
                    ChartModule,
                    LoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ChartSidebarWidgetModule, { declarations: [ChartSidebarWidgetComponent], imports: [CommonModule,
        WidgetPanelModule,
        FormsModule,
        ChartModule,
        LoadingSpinnerModule], exports: [ChartSidebarWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HistoryTimelineStore {
    constructor(listStoreFactory) {
        this.listStoreFactory = listStoreFactory;
        this.recordList = listStoreFactory.create();
    }
    clear() {
        this.recordList.clear();
        this.recordList = null;
    }
    clearAuthBased() {
        this.recordList.clearAuthBased();
    }
    /**
     * Initial list records load if not cached and update state.
     *
     * @param {ViewContext} context of parent
     * @description initialize the Record List Store
     * returns {void}
     */
    init(context) {
        this.recordList.init('history', false, 'list_max_entries_per_subpanel');
        this.initViewContext(context);
    }
    /**
     * Load / reload records using current pagination and criteria
     *
     * @param {boolean} useCache if to use cache
     * @returns {object} Observable<RecordList>
     */
    load(useCache = true) {
        return this.recordList.load(useCache);
    }
    /**
     * Init search criteria
     *
     * @param {number} offset of the recordset
     * @param {number} limit of the recordset
     * @description initialize the search module/criteria(offset/limit) for the record set
     */
    initSearchCriteria(offset, limit) {
        this.recordList.criteria = {
            preset: {
                type: 'history-timeline',
                params: {
                    parentModule: this.viewContext.module,
                    parentId: this.viewContext.id,
                    offset,
                    limit
                }
            }
        };
    }
    initViewContext(viewContext) {
        this.viewContext = viewContext;
    }
    static { this.ɵfac = function HistoryTimelineStore_Factory(t) { return new (t || HistoryTimelineStore)(i0.ɵɵinject(RecordListStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: HistoryTimelineStore, factory: HistoryTimelineStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistoryTimelineStore, [{
        type: Injectable
    }], function () { return [{ type: RecordListStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HistoryTimelineStoreFactory {
    constructor(listStoreFactory) {
        this.listStoreFactory = listStoreFactory;
    }
    create() {
        return new HistoryTimelineStore(this.listStoreFactory);
    }
    static { this.ɵfac = function HistoryTimelineStoreFactory_Factory(t) { return new (t || HistoryTimelineStoreFactory)(i0.ɵɵinject(RecordListStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: HistoryTimelineStoreFactory, factory: HistoryTimelineStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistoryTimelineStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordListStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HistoryTimelineAdapter {
    constructor(historyTimelineStoreFactory) {
        this.historyTimelineStoreFactory = historyTimelineStoreFactory;
        this.loading = false;
        this.cache = [];
        this.dataStream = new BehaviorSubject(this.cache);
        this.dataStream$ = this.dataStream.asObservable();
        this.defaultPageSize = 10;
    }
    /**
     * @returns {void}
     * @param {ViewContext} context - parent module context
     * @description adapter init function to initialize timeline store
     */
    init(context) {
        this.store = this.historyTimelineStoreFactory.create();
        this.store.init(context);
    }
    /**
     * @returns {Observable<HistoryTimelineEntry[]>} return observable array of timeline entries
     * @description retrieve next set of records starting from the current offset
     * represented by the field this.cache.length
     * @param {boolean} reload timeline
     */
    fetchTimelineEntries(reload) {
        if (this.loading === true) {
            return;
        }
        if (reload === true) {
            this.cache.length = 0;
        }
        this.store.initSearchCriteria(this.cache.length, this.defaultPageSize);
        this.loading = true;
        this.store.load(false).pipe(take(1)).subscribe(value => {
            this.loading = false;
            const records = value.records;
            if (!emptyObject(records)) {
                Object.keys(records).forEach(key => {
                    this.cache.push(this.buildTimelineEntry(records[key]));
                });
            }
            this.dataStream.next([...this.cache]);
        });
        return this.dataStream$;
    }
    /**
     * @returns {string} color code
     * @param {string} activity the valid activity types
     * @description {returns the mapped background color code defined for an activity}
     */
    getActivityGridColor(activity) {
        const colorMap = {
            calls: 'yellow',
            tasks: 'green',
            meetings: 'blue',
            notes: 'orange',
            audit: 'purple',
            history: 'purple'
        };
        return colorMap[activity] || 'yellow';
    }
    /**
     * @returns {HistoryTimelineEntry} Timeline Entry
     * @param {Record} record object
     * @description {returns the mapped record to timeline entry}
     */
    buildTimelineEntry(record) {
        const timelineModule = record.module;
        let moduleIcon = record.attributes.module_name;
        if (timelineModule === 'audit') {
            moduleIcon = 'History';
        }
        const gridColor = this.getActivityGridColor(record.module);
        const timelineEntry = {
            module: timelineModule,
            icon: moduleIcon,
            color: gridColor,
            title: {
                type: 'varchar',
                value: record.attributes.name
            },
            user: {
                type: 'varchar',
                value: record.attributes.assigned_user_name.user_name,
            },
            date: {
                type: 'datetime',
                value: record.attributes.date_end,
            },
            record
        };
        if (timelineModule === 'audit') {
            timelineEntry.description = {
                type: 'html',
                value: record.attributes.description
            };
        }
        return timelineEntry;
    }
    static { this.ɵfac = function HistoryTimelineAdapter_Factory(t) { return new (t || HistoryTimelineAdapter)(i0.ɵɵinject(HistoryTimelineStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: HistoryTimelineAdapter, factory: HistoryTimelineAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistoryTimelineAdapter, [{
        type: Injectable
    }], function () { return [{ type: HistoryTimelineStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HistoryTimelineAdapterFactory {
    constructor(historyTimelineStoreFactory) {
        this.historyTimelineStoreFactory = historyTimelineStoreFactory;
    }
    create() {
        return new HistoryTimelineAdapter(this.historyTimelineStoreFactory);
    }
    static { this.ɵfac = function HistoryTimelineAdapterFactory_Factory(t) { return new (t || HistoryTimelineAdapterFactory)(i0.ɵɵinject(HistoryTimelineStoreFactory)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: HistoryTimelineAdapterFactory, factory: HistoryTimelineAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistoryTimelineAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: HistoryTimelineStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function HistorySidebarWidgetComponent_div_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelement(1, "scrm-loading-spinner", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("overlay", true);
} }
function HistorySidebarWidgetComponent_div_1_scrm_chart_message_area_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-chart-message-area", 10);
} }
function HistorySidebarWidgetComponent_div_1_div_5_div_1_a_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a", 30);
    i0.ɵɵelement(1, "scrm-field", 27);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const entry_r5 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("routerLink", ctx_r7.redirectLink(entry_r5.record.module, entry_r5.record.id));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("type", entry_r5.title.type)("field", entry_r5.title)("record", entry_r5.record);
} }
function HistorySidebarWidgetComponent_div_1_div_5_div_1_a_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "a");
    i0.ɵɵelement(1, "scrm-field", 27);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const entry_r5 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("type", entry_r5.title.type)("field", entry_r5.title)("record", entry_r5.record);
} }
function HistorySidebarWidgetComponent_div_1_div_5_div_1_div_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 31)(1, "small", 26);
    i0.ɵɵelement(2, "scrm-field", 32);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const entry_r5 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("type", entry_r5.description.type)("field", entry_r5.description)("record", entry_r5.record);
} }
function HistorySidebarWidgetComponent_div_1_div_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "div", 12)(2, "div", 13)(3, "div", 14);
    i0.ɵɵelement(4, "scrm-image", 15);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(5, "div", 12)(6, "div", 16);
    i0.ɵɵelement(7, "div", 17);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(8, "div", 18)(9, "div", 19)(10, "div", 20)(11, "p", 21);
    i0.ɵɵtemplate(12, HistorySidebarWidgetComponent_div_1_div_5_div_1_a_12_Template, 2, 4, "a", 22);
    i0.ɵɵtemplate(13, HistorySidebarWidgetComponent_div_1_div_5_div_1_a_13_Template, 2, 3, "a", 23);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(14, HistorySidebarWidgetComponent_div_1_div_5_div_1_div_14_Template, 3, 3, "div", 24);
    i0.ɵɵelementStart(15, "div", 25)(16, "small", 26);
    i0.ɵɵelement(17, "scrm-field", 27);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(18, "div", 28)(19, "small", 29);
    i0.ɵɵelement(20, "scrm-field", 27);
    i0.ɵɵelementEnd()()()()()();
} if (rf & 2) {
    const entry_r5 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵclassMapInterpolate1("d-flex flex-row m-2 history-timeline-entry entry-", entry_r5.color, "");
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("image", entry_r5.icon);
    i0.ɵɵadvance(8);
    i0.ɵɵproperty("ngIf", entry_r5.record.module !== "audit");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", entry_r5.record.module === "audit");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", entry_r5.description);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("type", entry_r5.user.type)("field", entry_r5.user)("record", entry_r5.record);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("type", entry_r5.date.type)("field", entry_r5.date)("record", entry_r5.record);
} }
function HistorySidebarWidgetComponent_div_1_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtemplate(1, HistorySidebarWidgetComponent_div_1_div_5_div_1_Template, 21, 13, "div", 11);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.length > 0);
} }
const _c0$7 = function (a0) { return [a0]; };
function HistorySidebarWidgetComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    const _r16 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 2)(1, "div", 3);
    i0.ɵɵtemplate(2, HistorySidebarWidgetComponent_div_1_div_2_Template, 2, 1, "div", 4);
    i0.ɵɵelementStart(3, "cdk-virtual-scroll-viewport", 5);
    i0.ɵɵlistener("scroll", function HistorySidebarWidgetComponent_div_1_Template_cdk_virtual_scroll_viewport_scroll_3_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r15.onScroll()); });
    i0.ɵɵtemplate(4, HistorySidebarWidgetComponent_div_1_scrm_chart_message_area_4_Template, 1, 0, "scrm-chart-message-area", 6);
    i0.ɵɵtemplate(5, HistorySidebarWidgetComponent_div_1_div_5_Template, 2, 1, "div", 7);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.adapter == null ? null : ctx_r0.adapter.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(4, _c0$7, vm_r1.length <= 0 ? "history-timeline-viewport-no-data" : "history-timeline-viewport"));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !(ctx_r0.adapter == null ? null : ctx_r0.adapter.loading) && vm_r1.length <= 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", vm_r1);
} }
class HistorySidebarWidgetComponent extends BaseWidgetComponent {
    constructor(historyTimelineAdapterFactory, languageStore, navigation) {
        super();
        this.historyTimelineAdapterFactory = historyTimelineAdapterFactory;
        this.languageStore = languageStore;
        this.navigation = navigation;
        this.subscription = new Subscription();
    }
    ngOnInit() {
        this.adapter = this.historyTimelineAdapterFactory.create();
        this.adapter.init(this.context);
    }
    ngAfterViewInit() {
        // watch out for the data list updates on the related subpanels activities and history
        // reload request will be ignored;
        // if they are notified multiple times within the dueTime/delay 500 ms
        const reloadMap = [];
        reloadMap.push(this.config.reload$);
        reloadMap.push(this.config.subpanelReload$);
        const subpanelsToWatch = ['history', 'activities'];
        const reload$ = reloadMap[0].pipe(combineLatestWith(...reloadMap), map(([reload, subpanelReload = {}]) => {
            if (reload) {
                return reload;
            }
            if (!subpanelReload) {
                return false;
            }
            return subpanelsToWatch.some(subpanelKey => !!subpanelReload[subpanelKey]);
        }));
        const debouncedReload = reload$.pipe(debounce(() => timer(1000)));
        this.subscription.add(debouncedReload.subscribe(reload => {
            if (reload) {
                this.adapter.fetchTimelineEntries(true);
            }
        }));
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    /**
     * @returns {string} Timeline Entry
     * @description {fetch language label for the timeline widget header}
     */
    getHeaderLabel() {
        return this.languageStore.getFieldLabel('LBL_QUICK_HISTORY');
    }
    /**
     * @returns {void} Timeline Entry
     * @description {checks if end of the scroll is reached to make a backend call for next set of timeline entries}
     */
    onScroll() {
        if (!this.adapter) {
            return;
        }
        const scrollOffset = this.virtualScroll.measureScrollOffset('bottom');
        if (floor(scrollOffset) === 0) {
            this.adapter.fetchTimelineEntries(false);
        }
    }
    redirectLink(module, id) {
        if (module === 'audit') {
            return;
        }
        return this.navigation.getRecordRouterLink(module, id);
    }
    static { this.ɵfac = function HistorySidebarWidgetComponent_Factory(t) { return new (t || HistorySidebarWidgetComponent)(i0.ɵɵdirectiveInject(HistoryTimelineAdapterFactory), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ModuleNavigation)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: HistorySidebarWidgetComponent, selectors: [["scrm-history-timeline-widget"]], viewQuery: function HistorySidebarWidgetComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(CdkVirtualScrollViewport, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.virtualScroll = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([HistoryTimelineAdapter]), i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 4, consts: [[3, "title"], ["widget-body", "", 4, "ngIf"], ["widget-body", ""], [1, "widget-background", "history-timeline", "p-2", "pt-2"], ["class", "d-flex record-thread-loading justify-content-center", 4, "ngIf"], ["itemSize", "100", 1, "history-timeline-viewport", 3, "ngClass", "scroll"], ["labelKey", "LBL_NO_DATA", 4, "ngIf"], [4, "ngFor", "ngForOf"], [1, "d-flex", "record-thread-loading", "justify-content-center"], [3, "overlay"], ["labelKey", "LBL_NO_DATA"], [3, "class", 4, "ngIf"], [1, ""], [1, "circle"], [1, "d-flex", "justify-content-center", "align-items-center", "h-100", "history-timeline-image"], [3, "image"], [1, "d-flex", "justify-content-center", "h-100"], [1, "connector", "mt-3"], [1, "flex-grow-1"], [1, "card"], [1, "card-body", "p-1", "pr-2", "pl-2"], [1, "card-title", "text-break", "history-timeline-entry-title"], [3, "routerLink", 4, "ngIf"], [4, "ngIf"], ["class", "card-text history-timeline-entry-description", 4, "ngIf"], [1, "card-text", "history-timeline-entry-user", "text-uppercase"], [1, "text-break"], ["mode", "list", 3, "type", "field", "record"], [1, "card-text", "text-break", "history-timeline-entry-date"], [1, "font-italic"], [3, "routerLink"], [1, "card-text", "history-timeline-entry-description"], ["mode", "detail", 3, "type", "field", "record"]], template: function HistorySidebarWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-widget-panel", 0);
            i0.ɵɵtemplate(1, HistorySidebarWidgetComponent_div_1_Template, 6, 6, "div", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("title", ctx.getHeaderLabel());
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 2, ctx.adapter == null ? null : ctx.adapter.dataStream$));
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i5$4.CdkFixedSizeVirtualScroll, i5$4.CdkVirtualScrollViewport, ImageComponent, FieldComponent, WidgetPanelComponent, LoadingSpinnerComponent, ChartMessageAreaComponent, i1$2.RouterLink, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistorySidebarWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-history-timeline-widget', providers: [HistoryTimelineAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-widget-panel [title]=\"getHeaderLabel()\">\n    <div widget-body *ngIf=\"(adapter?.dataStream$| async) as vm\">\n\n        <div class=\"widget-background history-timeline p-2 pt-2\">\n\n            <div *ngIf=\"adapter?.loading\" class=\"d-flex record-thread-loading justify-content-center\">\n                <scrm-loading-spinner [overlay]=\"true\"></scrm-loading-spinner>\n            </div>\n\n            <cdk-virtual-scroll-viewport itemSize=\"100\"\n                                         class=\"history-timeline-viewport\"\n                                         [ngClass]=\"[vm.length <= 0 ? 'history-timeline-viewport-no-data' : 'history-timeline-viewport']\"\n                                         (scroll)=\"onScroll()\">\n\n                <scrm-chart-message-area *ngIf=\"!adapter?.loading && vm.length <= 0\"\n                                         labelKey=\"LBL_NO_DATA\"></scrm-chart-message-area>\n\n                <div *ngFor=\"let entry of vm;\">\n                    <div *ngIf=\"vm.length > 0\"\n                         class=\"d-flex flex-row m-2 history-timeline-entry entry-{{entry.color}}\">\n                        <div class=\"\">\n                            <div class=\"circle\">\n                                <div\n                                    class=\"d-flex justify-content-center align-items-center h-100 history-timeline-image\">\n                                    <scrm-image [image]=\"entry.icon\"></scrm-image>\n                                </div>\n                            </div>\n                        </div>\n                        <div class=\"\">\n                            <div class=\"d-flex justify-content-center h-100\">\n                                <div class=\"connector mt-3\">\n                                </div>\n                            </div>\n\n                        </div>\n                        <div class=\"flex-grow-1\">\n\n                            <div class=\"card\">\n                                <div class=\"card-body p-1 pr-2 pl-2\">\n                                    <p class=\"card-title text-break history-timeline-entry-title\">\n                                        <a *ngIf=\"entry.record.module !== 'audit'\"\n                                           [routerLink]=\"redirectLink(entry.record.module, entry.record.id)\"\n                                        >\n                                        <scrm-field [type]=\"entry.title.type\"\n                                                    mode=\"list\"\n                                                    [field]=\"entry.title\"\n                                                    [record]=\"entry.record\">\n                                        </scrm-field>\n                                        </a>\n                                        <a *ngIf=\"entry.record.module === 'audit'\">\n                                            <scrm-field [type]=\"entry.title.type\"\n                                                        mode=\"list\"\n                                                        [field]=\"entry.title\"\n                                                        [record]=\"entry.record\">\n                                            </scrm-field>\n                                        </a>\n                                    </p>\n                                    <div *ngIf=\"entry.description\"\n                                         class=\"card-text history-timeline-entry-description\">\n                                        <small class=\"text-break\">\n                                            <scrm-field [type]=\"entry.description.type\"\n                                                        mode=\"detail\"\n                                                        [field]=\"entry.description\"\n                                                        [record]=\"entry.record\">\n                                            </scrm-field>\n                                        </small>\n                                    </div>\n                                    <div class=\"card-text history-timeline-entry-user text-uppercase\">\n                                        <small class=\"text-break\">\n                                            <scrm-field [type]=\"entry.user.type\"\n                                                        mode=\"list\"\n                                                        [field]=\"entry.user\"\n                                                        [record]=\"entry.record\">\n                                            </scrm-field>\n                                        </small>\n                                    </div>\n                                    <div class=\"card-text text-break history-timeline-entry-date\">\n                                        <small class=\"font-italic\">\n                                            <scrm-field [type]=\"entry.date.type\"\n                                                        mode=\"list\"\n                                                        [field]=\"entry.date\"\n                                                        [record]=\"entry.record\"></scrm-field>\n                                        </small>\n                                    </div>\n                                </div>\n                            </div>\n\n                        </div>\n                    </div>\n\n                </div>\n            </cdk-virtual-scroll-viewport>\n        </div>\n    </div>\n</scrm-widget-panel>\n" }]
    }], function () { return [{ type: HistoryTimelineAdapterFactory }, { type: LanguageStore }, { type: ModuleNavigation }]; }, { virtualScroll: [{
            type: ViewChild,
            args: [CdkVirtualScrollViewport]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HistorySidebarWidgetModule {
    static { this.ɵfac = function HistorySidebarWidgetModule_Factory(t) { return new (t || HistorySidebarWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: HistorySidebarWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ScrollingModule,
            ImageModule,
            FieldModule,
            WidgetPanelModule,
            LoadingSpinnerModule,
            LabelModule,
            ChartMessageAreaModule,
            RouterModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HistorySidebarWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [HistorySidebarWidgetComponent],
                exports: [
                    HistorySidebarWidgetComponent
                ],
                imports: [
                    CommonModule,
                    ScrollingModule,
                    ImageModule,
                    FieldModule,
                    WidgetPanelModule,
                    LoadingSpinnerModule,
                    LabelModule,
                    ChartMessageAreaModule,
                    RouterModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(HistorySidebarWidgetModule, { declarations: [HistorySidebarWidgetComponent], imports: [CommonModule,
        ScrollingModule,
        ImageModule,
        FieldModule,
        WidgetPanelModule,
        LoadingSpinnerModule,
        LabelModule,
        ChartMessageAreaModule,
        RouterModule], exports: [HistorySidebarWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordThreadSidebarWidgetComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵelement(2, "scrm-label", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} }
function RecordThreadSidebarWidgetComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-thread", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r1.recordThreadConfig);
} }
class RecordThreadSidebarWidgetComponent extends BaseWidgetComponent {
    constructor(language, sytemConfig) {
        super();
        this.language = language;
        this.sytemConfig = sytemConfig;
        this.panelMode = 'none';
        this.subs = [];
    }
    ngOnInit() {
        const options = this.config.options || {};
        this.options = options.recordThread || null;
        if (!this.options) {
            return;
        }
        this.initPanelMode();
        this.initFilters$();
        this.initPresetFields$();
        if (this.context$ && this.context$.subscribe()) {
            this.subs.push(this.context$.subscribe((context) => {
                this.context = context;
            }));
        }
        this.recordThreadConfig = this.getConfig();
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getHeaderLabel() {
        return this.getLabel(this.config.labelKey) || '';
    }
    getLabel(key) {
        const context = this.context || {};
        const module = context.module || '';
        return this.language.getFieldLabel(key, module);
    }
    getConfig() {
        const config = {
            filters$: this.filters$,
            presetFields$: this.presetFields$,
            module: this.options.module,
            klass: this.options.class || '',
            maxListHeight: this.options.maxListHeight ?? 350,
            direction: this.options.direction || 'asc',
            create: !!this?.options?.create,
            createConfig: {},
            itemConfig: {
                collapsible: this.options.item.collapsible || false,
                collapseLimit: this.options.item.collapseLimit || null,
                klass: this.options.item.itemClass || '',
                dynamicClass: this.options.item.dynamicClass || [],
                metadata: {}
            },
            listActions: this?.options?.listActions ?? null,
            collapseListActions: this?.options?.collapseListActions ?? false,
            listActionsClass: this?.options?.listActionsClass ?? '',
            listActionsButtonClass: this?.options?.listActionsButtonClass ?? '',
            listActionsButtonGroupClass: this?.options?.listActionsButtonGroupClass ?? '',
        };
        this.setupItemMetadata(config.itemConfig.metadata, this.options.item.layout);
        if (!isEmpty(this.options?.create ?? null)) {
            config.createConfig = {
                collapsible: false,
                metadata: {}
            };
            this.setupItemMetadata(config.createConfig.metadata, this.options?.create?.layout ?? {});
        }
        return config;
    }
    setupItemMetadata(metadata, config) {
        if (config && config.header) {
            metadata.headerLayout = deepClone(config.header);
        }
        if (config && config.body) {
            metadata.bodyLayout = deepClone(config.body);
        }
        if (config && config.actions) {
            metadata.actions = deepClone(config.actions);
        }
        if (config && config.fields) {
            metadata.fields = deepClone(config.fields);
        }
        if ((config?.collapseActions ?? null) !== null) {
            metadata.collapseActions = config?.collapseActions;
        }
    }
    initPanelMode() {
        const ui = this.sytemConfig.getConfigValue('ui');
        const systemDefault = ui?.widget?.allowCollapse ?? null;
        const allowCollapse = this?.config?.allowCollapse ?? null;
        let mode = 'none';
        if (systemDefault !== null) {
            if (isTrue(systemDefault)) {
                mode = 'collapsible';
            }
            else if (isFalse(systemDefault)) {
                mode = 'none';
            }
        }
        if (allowCollapse !== null) {
            if (isTrue(allowCollapse)) {
                mode = 'collapsible';
            }
            else if (isFalse(allowCollapse)) {
                mode = 'none';
            }
        }
        this.panelMode = mode;
    }
    initFilters$() {
        if (!this.options || !this.options.filters || !this.context$) {
            return;
        }
        const parentFilters = this.options.filters.parentFilters || {};
        let context$ = of({}).pipe(shareReplay());
        if (Object.keys(parentFilters).length > 0) {
            context$ = this.context$.pipe(filter(context => {
                const record = (context && context.record) || {};
                return !!(record.attributes && Object.keys(record.attributes).length);
            }));
        }
        this.filters$ = context$.pipe(map(context => {
            const filters = { filters: {} };
            this.initParentFilters(context, filters);
            const staticFilters = this.options.filters.static || {};
            filters.filters = {
                ...filters.filters,
                ...staticFilters
            };
            if (this.options.filters.orderBy) {
                filters.orderBy = this.options.filters.orderBy;
            }
            if (this.options.filters.sortOrder) {
                filters.sortOrder = this.options.filters.sortOrder;
            }
            return filters;
        }), distinctUntilChanged());
    }
    initPresetFields$() {
        if (!this.options || !this.options.create || !this.options.create.presetFields || !this.context$) {
            return;
        }
        this.presetFields$ = this.context$.pipe(map(context => {
            const parentValues = this.initParentValues(context);
            const staticValues = this.options.create.presetFields.static || {};
            return {
                ...parentValues,
                ...staticValues
            };
        }), distinctUntilChanged());
    }
    initParentFilters(context, filters) {
        const parentFilters = this.options.filters.parentFilters || {};
        if (!context || !context.record || !parentFilters) {
            return;
        }
        Object.keys(parentFilters).forEach(parentField => {
            const field = parentFilters[parentField];
            const value = context.record.attributes[parentField] || '';
            if (!value) {
                return;
            }
            filters.filters[field] = {
                field: parentFilters,
                operator: '=',
                values: [value],
            };
        });
    }
    initParentValues(context) {
        const parentValues = this.options.create.presetFields.parentValues || {};
        if (!context || !context.record || !parentValues) {
            return;
        }
        const attributes = {};
        Object.keys(parentValues).forEach(parentField => {
            const field = parentValues[parentField];
            const value = context.record.attributes[parentField] || '';
            if (!value) {
                return;
            }
            attributes[field] = value;
        });
        return attributes;
    }
    static { this.ɵfac = function RecordThreadSidebarWidgetComponent_Factory(t) { return new (t || RecordThreadSidebarWidgetComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordThreadSidebarWidgetComponent, selectors: [["scrm-record-thread-sidebar-widget"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 4, vars: 4, consts: [[3, "mode", "title"], ["widget-body", "", 1, "record-thread-sidebar-widget"], [4, "ngIf"], [1, "p-3", "widget-message"], ["labelKey", "LBL_BAD_CONFIG"], [3, "config"]], template: function RecordThreadSidebarWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-widget-panel", 0)(1, "div", 1);
            i0.ɵɵtemplate(2, RecordThreadSidebarWidgetComponent_ng_container_2_Template, 3, 0, "ng-container", 2);
            i0.ɵɵtemplate(3, RecordThreadSidebarWidgetComponent_ng_container_3_Template, 2, 1, "ng-container", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("mode", ctx.panelMode)("title", ctx.getHeaderLabel());
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", !ctx.options);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.options);
        } }, dependencies: [i2.NgIf, WidgetPanelComponent, LabelComponent, RecordThreadComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadSidebarWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-thread-sidebar-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-widget-panel [mode]=\"panelMode\" [title]=\"getHeaderLabel()\">\n    <div class=\"record-thread-sidebar-widget\" widget-body>\n\n        <ng-container *ngIf=\"!options\">\n            <div class=\"p-3 widget-message\">\n                <scrm-label labelKey=\"LBL_BAD_CONFIG\"></scrm-label>\n            </div>\n        </ng-container>\n\n        <ng-container *ngIf=\"options\">\n            <scrm-record-thread [config]=\"recordThreadConfig\"></scrm-record-thread>\n        </ng-container>\n\n    </div>\n</scrm-widget-panel>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordThreadSidebarWidgetModule {
    static { this.ɵfac = function RecordThreadSidebarWidgetModule_Factory(t) { return new (t || RecordThreadSidebarWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordThreadSidebarWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            WidgetPanelModule,
            LabelModule,
            RecordThreadModule,
            RecordThreadItemModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordThreadSidebarWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordThreadSidebarWidgetComponent],
                exports: [
                    RecordThreadSidebarWidgetComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    WidgetPanelModule,
                    LabelModule,
                    RecordThreadModule,
                    RecordThreadItemModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordThreadSidebarWidgetModule, { declarations: [RecordThreadSidebarWidgetComponent], imports: [CommonModule,
        FieldModule,
        WidgetPanelModule,
        LabelModule,
        RecordThreadModule,
        RecordThreadItemModule], exports: [RecordThreadSidebarWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsSidebarWidgetComponent extends BaseWidgetComponent {
    constructor(language) {
        super();
        this.language = language;
        this.subs = [];
    }
    ngOnInit() {
        const options = this.config.options || {};
        this.options = options.sidebarStatistic || null;
        if (this.context$) {
            this.subs.push(this.context$.subscribe((context) => {
                this.context = context;
            }));
        }
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    getHeaderLabel() {
        return this.getLabel(this.config.labelKey) || '';
    }
    getLabel(key) {
        const context = this.context || {};
        const module = context.module || '';
        return this.language.getFieldLabel(key, module);
    }
    getGridConfig() {
        return {
            rowClass: 'statistics-sidebar-widget-row',
            columnClass: 'statistics-sidebar-widget-col',
            layout: this.options,
            widgetConfig: { reload$: this.config.reload$ },
            queryArgs: {
                module: this.context.module,
                context: this.context,
                params: {},
            },
        };
    }
    static { this.ɵfac = function StatisticsSidebarWidgetComponent_Factory(t) { return new (t || StatisticsSidebarWidgetComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StatisticsSidebarWidgetComponent, selectors: [["scrm-statistics-sidebar-widget"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 3, vars: 2, consts: [[3, "title"], ["widget-body", "", 1, "p-3"], [3, "config"]], template: function StatisticsSidebarWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "scrm-widget-panel", 0)(1, "div", 1);
            i0.ɵɵelement(2, "scrm-grid-widget", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("title", ctx.getHeaderLabel());
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("config", ctx.getGridConfig());
        } }, dependencies: [WidgetPanelComponent, GridWidgetComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsSidebarWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-statistics-sidebar-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<scrm-widget-panel [title]=\"getHeaderLabel()\">\n    <div widget-body class=\"p-3\">\n\n        <scrm-grid-widget [config]=\"getGridConfig()\"></scrm-grid-widget>\n\n    </div>\n</scrm-widget-panel>\n" }]
    }], function () { return [{ type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsSidebarWidgetModule {
    static { this.ɵfac = function StatisticsSidebarWidgetModule_Factory(t) { return new (t || StatisticsSidebarWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: StatisticsSidebarWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            InlineLoadingSpinnerModule,
            WidgetPanelModule,
            GridWidgetModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsSidebarWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [StatisticsSidebarWidgetComponent],
                exports: [
                    StatisticsSidebarWidgetComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    InlineLoadingSpinnerModule,
                    WidgetPanelModule,
                    GridWidgetModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(StatisticsSidebarWidgetModule, { declarations: [StatisticsSidebarWidgetComponent], imports: [CommonModule,
        FieldModule,
        InlineLoadingSpinnerModule,
        WidgetPanelModule,
        GridWidgetModule,
        LabelModule], exports: [StatisticsSidebarWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const sidebarWidgetModules = [
    HistorySidebarWidgetModule,
    ChartSidebarWidgetModule,
    StatisticsSidebarWidgetModule
];
const componentTypeMap = {
    'history-timeline': HistorySidebarWidgetComponent,
    chart: ChartSidebarWidgetComponent,
    statistics: StatisticsSidebarWidgetComponent,
    'record-thread': RecordThreadSidebarWidgetComponent
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SidebarWidgetRegistry extends BaseComponentRegistry {
    constructor() {
        super();
    }
    initDefault() {
        Object.keys(componentTypeMap).forEach(key => {
            this.register('default', key, componentTypeMap[key]);
        });
    }
    static { this.ɵfac = function SidebarWidgetRegistry_Factory(t) { return new (t || SidebarWidgetRegistry)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SidebarWidgetRegistry, factory: SidebarWidgetRegistry.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarWidgetRegistry, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function SidebarWidgetComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2)(1, "div", 3);
    i0.ɵɵelement(2, "scrm-label", 4);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("labelKey", ctx_r0.getErrorMessage());
} }
const _c0$6 = function (a0, a1, a2) { return { "config": a0, "context": a1, "context$": a2 }; };
function SidebarWidgetComponent_ndc_dynamic_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 5);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r1.componentType)("ndcDynamicInputs", i0.ɵɵpureFunction3(2, _c0$6, ctx_r1.config, ctx_r1.context, ctx_r1.context$));
} }
class SidebarWidgetComponent extends BaseWidgetComponent {
    constructor(registry) {
        super();
        this.registry = registry;
    }
    get componentType() {
        const module = this.context.module ?? 'default';
        return this.registry.get(module, this.type);
    }
    getErrorMessage() {
        if (!this.type || !this.config) {
            return 'LBL_CONFIG_NO_CONFIG';
        }
        if (!this.componentType) {
            return 'LBL_WIDGET_NOT_FOUND';
        }
        return 'LBL_BAD_CONFIG';
    }
    static { this.ɵfac = function SidebarWidgetComponent_Factory(t) { return new (t || SidebarWidgetComponent)(i0.ɵɵdirectiveInject(SidebarWidgetRegistry)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SidebarWidgetComponent, selectors: [["scrm-sidebar-widget"]], inputs: { type: "type" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [["class", "d-flex mb-4 mt-4 justify-content-center", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [1, "d-flex", "mb-4", "mt-4", "justify-content-center"], [1, "lead"], [3, "labelKey"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function SidebarWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SidebarWidgetComponent_div_0_Template, 3, 1, "div", 0);
            i0.ɵɵtemplate(1, SidebarWidgetComponent_ndc_dynamic_1_Template, 1, 6, "ndc-dynamic", 1);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", !(ctx.type && ctx.config && ctx.componentType));
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.type && ctx.config && ctx.componentType);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-sidebar-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"!(type && config && componentType)\"\n     class=\"d-flex mb-4 mt-4 justify-content-center\">\n    <div class=\"lead\">\n        <scrm-label [labelKey]=\"getErrorMessage()\"></scrm-label>\n    </div>\n</div>\n<ndc-dynamic *ngIf=\"type && config && componentType\"\n             [ndcDynamicComponent]=\"componentType\"\n             [ndcDynamicInputs]=\"{\n                'config': config,\n                'context': context,\n                'context$': context$\n            }\"\n></ndc-dynamic>\n" }]
    }], function () { return [{ type: SidebarWidgetRegistry }]; }, { type: [{
            type: Input,
            args: ['type']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SidebarWidgetModule {
    static { this.ɵfac = function SidebarWidgetModule_Factory(t) { return new (t || SidebarWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SidebarWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule, sidebarWidgetModules, DynamicModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [SidebarWidgetComponent],
                exports: [SidebarWidgetComponent],
                imports: [
                    CommonModule,
                    ...sidebarWidgetModules,
                    DynamicModule,
                    LabelModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SidebarWidgetModule, { declarations: [SidebarWidgetComponent], imports: [CommonModule, HistorySidebarWidgetModule, ChartSidebarWidgetModule, StatisticsSidebarWidgetModule, DynamicModule,
        LabelModule], exports: [SidebarWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelActionHandler extends ActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessSubpanelAction extends SubpanelActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function AsyncProcessSubpanelAction_Factory(t) { return new (t || AsyncProcessSubpanelAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessSubpanelAction, factory: AsyncProcessSubpanelAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessSubpanelAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelClearFilterAction extends SubpanelActionHandler {
    constructor() {
        super(...arguments);
        this.key = 'clear-filter';
        this.modes = ['list'];
    }
    shouldDisplay(data) {
        return this.isAnyFilterApplied(data.store);
    }
    run(data) {
        data.store.clearFilter();
    }
    isAnyFilterApplied(store) {
        return store.hasActiveFilter() || !store.areAllCurrentCriteriaFilterEmpty();
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵSubpanelClearFilterAction_BaseFactory; return function SubpanelClearFilterAction_Factory(t) { return (ɵSubpanelClearFilterAction_BaseFactory || (ɵSubpanelClearFilterAction_BaseFactory = i0.ɵɵgetInheritedFactory(SubpanelClearFilterAction)))(t || SubpanelClearFilterAction); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelClearFilterAction, factory: SubpanelClearFilterAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelClearFilterAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelCreateAction extends SubpanelActionHandler {
    constructor(moduleNameMapper, router) {
        super();
        this.moduleNameMapper = moduleNameMapper;
        this.router = router;
        this.key = 'create';
        this.modes = ['list'];
    }
    run(data) {
        const moduleName = data.module;
        const moduleAction = data?.action?.moduleAction ?? 'edit';
        const parentId = data?.parentId ?? '';
        const parentModule = data.parentModule ?? '';
        const route = `/${moduleName}/${moduleAction}`;
        const queryParams = {
            // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
            return_module: this.moduleNameMapper.toLegacy(parentModule),
            // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
            return_action: 'DetailView',
            // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
            return_id: parentId,
            relate_to: parentModule,
            relate_id: parentId,
        };
        this.addAdditionalFields(data, queryParams);
        this.addParams(data, queryParams);
        this.router.navigate([route], {
            queryParams
        }).then();
    }
    shouldDisplay() {
        return true;
    }
    /**
     * Add additional record fields
     *
     * @param {object} data SubpanelActionData
     * @param {object} queryParams Params map
     */
    addAdditionalFields(data, queryParams) {
        const parentAttributes = (data.store.parentRecord && data.store.parentRecord.attributes) || {};
        if (!parentAttributes && !Object.keys(parentAttributes).length) {
            return;
        }
        const additionalFields = data.action.additionalFields ?? {};
        const additionalFieldKeys = Object.keys(additionalFields) || [];
        additionalFieldKeys.forEach(additionalFieldKey => {
            if (!additionalFieldKey || !additionalFields[additionalFieldKey]) {
                return;
            }
            const parentAttribute = additionalFields[additionalFieldKey];
            const attribute = get(parentAttributes, parentAttribute, null);
            if (isVoid(attribute)) {
                return;
            }
            queryParams[additionalFieldKey] = attribute;
        });
    }
    /**
     * Add configuration defined params
     *
     * @param {object} data SubpanelActionData
     * @param {object} queryParams Params map
     */
    addParams(data, queryParams) {
        const params = data.action.extraParams ?? {};
        const paramKeys = Object.keys(params) || [];
        paramKeys.forEach(paramKey => {
            if (!paramKey || !params[paramKey]) {
                return;
            }
            queryParams[paramKey] = params[paramKey];
        });
    }
    static { this.ɵfac = function SubpanelCreateAction_Factory(t) { return new (t || SubpanelCreateAction)(i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(i1$2.Router)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelCreateAction, factory: SubpanelCreateAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelCreateAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ModuleNameMapper }, { type: i1$2.Router }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelSelectAction extends SubpanelActionHandler {
    constructor(modalService, message, asyncActionService) {
        super();
        this.modalService = modalService;
        this.message = message;
        this.asyncActionService = asyncActionService;
        this.key = 'select';
        this.modes = ['list'];
    }
    shouldDisplay(data) {
        return true;
    }
    run(data) {
        this.showSelectModal(data);
    }
    /**
     * Show record selection modal
     */
    showSelectModal(data) {
        const modal = this.modalService.open(RecordListModalComponent, { size: 'xl', scrollable: true });
        const module = data.module;
        modal.componentInstance.module = module;
        modal.componentInstance.parentModule = data?.parentModule ?? '';
        modal.componentInstance.multiSelect = true;
        modal.componentInstance.multiSelectButtonLabel = 'LBL_LINK';
        modal.result.then((result) => {
            if (!result || !result.selection || !result.selection.selected) {
                return;
            }
            const recordIds = this.getSelectedIds(result);
            let linkField = data.subpanelMeta.get_subpanel_data;
            const collectionList = data.subpanelMeta?.collection_list ?? null;
            if (collectionList && collectionList?.[module]?.get_subpanel_data) {
                linkField = collectionList[module].get_subpanel_data;
            }
            const input = {
                action: 'record-select',
                module: data.store.parentModule,
                id: data.store.parentId || '',
                payload: {
                    baseModule: data.parentModule,
                    baseRecordId: data.parentId,
                    linkField,
                    relateModule: module,
                    relateRecordIds: recordIds
                },
            };
            this.runAsyncAction(input, data);
        });
    }
    /**
     * Get Selected Record
     *
     * @param {object} data RecordListModalResult
     * @returns {object} Record
     **/
    getSelectedIds(data) {
        const ids = [];
        Object.keys(data.selection.selected).forEach((selected) => {
            if (selected) {
                ids.push(selected);
            }
        });
        return ids;
    }
    runAsyncAction(asyncData, data) {
        const actionName = 'record-select';
        this.message.removeMessages();
        this.asyncActionService.run(actionName, asyncData).pipe(take(1)).subscribe(() => {
            data.store.load(false).pipe(take(1)).subscribe();
            data.store.loadAllStatistics(false).pipe(take(1)).subscribe();
        });
    }
    static { this.ɵfac = function SubpanelSelectAction_Factory(t) { return new (t || SubpanelSelectAction)(i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(MessageService), i0.ɵɵinject(AsyncActionService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelSelectAction, factory: SubpanelSelectAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelSelectAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i3$1.NgbModal }, { type: MessageService }, { type: AsyncActionService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelShowFilterAction extends SubpanelActionHandler {
    constructor() {
        super(...arguments);
        this.key = 'show-filter';
        this.modes = ['list'];
    }
    shouldDisplay(data) {
        return true;
    }
    getStatus(data) {
        if (this.isAnyFilterApplied(data.store)) {
            return 'active';
        }
        return '';
    }
    run(data) {
        data.store.toggleFilter();
    }
    isAnyFilterApplied(store) {
        return store.hasActiveFilter() || !store.areAllCurrentCriteriaFilterEmpty();
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵSubpanelShowFilterAction_BaseFactory; return function SubpanelShowFilterAction_Factory(t) { return (ɵSubpanelShowFilterAction_BaseFactory || (ɵSubpanelShowFilterAction_BaseFactory = i0.ɵɵgetInheritedFactory(SubpanelShowFilterAction)))(t || SubpanelShowFilterAction); }; }(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelShowFilterAction, factory: SubpanelShowFilterAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelShowFilterAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelActionManager extends BaseActionManager {
    constructor(create, select, async, showFilter, clearFilter) {
        super();
        this.create = create;
        this.select = select;
        this.async = async;
        this.showFilter = showFilter;
        this.clearFilter = clearFilter;
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
        create.modes.forEach(mode => this.actions[mode][create.key] = create);
        select.modes.forEach(mode => this.actions[mode][select.key] = select);
        showFilter.modes.forEach(mode => this.actions[mode][showFilter.key] = showFilter);
        clearFilter.modes.forEach(mode => this.actions[mode][clearFilter.key] = clearFilter);
    }
    static { this.ɵfac = function SubpanelActionManager_Factory(t) { return new (t || SubpanelActionManager)(i0.ɵɵinject(SubpanelCreateAction), i0.ɵɵinject(SubpanelSelectAction), i0.ɵɵinject(AsyncProcessSubpanelAction), i0.ɵɵinject(SubpanelShowFilterAction), i0.ɵɵinject(SubpanelClearFilterAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelActionManager, factory: SubpanelActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SubpanelCreateAction }, { type: SubpanelSelectAction }, { type: AsyncProcessSubpanelAction }, { type: SubpanelShowFilterAction }, { type: SubpanelClearFilterAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    getActions(context) {
        return this.store.metadata$.pipe(combineLatestWith(this.language.vm$, this.store.criteria$), map(([meta, language, criteria]) => {
            if (!meta) {
                return [];
            }
            return this.parseModeActions(meta.top_buttons, "list");
        }));
    }
    buildActionData(action, context) {
        return {
            subpanelMeta: this.store?.metadata,
            module: action.module || this.store.metadata?.module,
            parentModule: this.store.parentModule,
            parentId: this.store.parentId,
            store: this.store,
            action
        };
    }
    getMode() {
        return 'list';
    }
    getModuleName(context) {
        return this.store?.metadata?.module;
    }
    reload(action, process, context) {
        this.store.load(false).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function SubpanelActionsAdapter_Factory(t) { return new (t || SubpanelActionsAdapter)(i0.ɵɵinject(SubpanelStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SubpanelActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelActionsAdapter, factory: SubpanelActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: SubpanelStore }, { type: LanguageStore }, { type: SubpanelActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelActionAdapterFactory {
    constructor(language, actionManager, asyncActionService, message, confimation, selectModalService, metadata, appMetadataStore) {
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confimation = confimation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store) {
        return new SubpanelActionsAdapter(store, this.language, this.actionManager, this.asyncActionService, this.message, this.confimation, this.selectModalService, this.metadata, this.appMetadataStore);
    }
    static { this.ɵfac = function SubpanelActionAdapterFactory_Factory(t) { return new (t || SubpanelActionAdapterFactory)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SubpanelActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelActionAdapterFactory, factory: SubpanelActionAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelActionAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LanguageStore }, { type: SubpanelActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelFilterAdapter {
    constructor(store) {
        this.store = store;
    }
    getConfig() {
        return {
            panelMode: 'collapsible',
            collapseOnSearch: true,
            savedFilterEdit: false,
            module: this.store.recordList.getModule(),
            displayHeader: false,
            filter$: this.store.recordList.openFilter$,
            savedFilters$: this.store.filterList.records$,
            searchFields$: this.store.searchMetadata$.pipe(map((searchMeta) => {
                if (this.store.metadata.searchdefs) {
                    return this.store.metadata.searchdefs;
                }
                if (!searchMeta) {
                    return {};
                }
                let type = 'advanced';
                if (!searchMeta?.layout?.advanced) {
                    type = 'basic';
                }
                return searchMeta?.layout[type];
            })),
            listFields: [],
            onClose: () => {
            },
            onSearch: () => {
                this.store.searchFilter();
            },
            updateFilter: (filter, reload = true) => {
                const filters = {};
                filters[filter.key] = filter;
                this.store.setFilters(filters, reload);
            },
            resetFilter: (reload) => {
                this.store.resetFilters(reload);
            },
            addSavedFilter: (filter) => {
            },
            removeSavedFilter: (filter) => {
            },
            setOpenFilter: (filter) => {
            },
        };
    }
    static { this.ɵfac = function SubpanelFilterAdapter_Factory(t) { return new (t || SubpanelFilterAdapter)(i0.ɵɵinject(SubpanelStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelFilterAdapter, factory: SubpanelFilterAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelFilterAdapter, [{
        type: Injectable
    }], function () { return [{ type: SubpanelStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelFilterAdapterFactory {
    create(store) {
        return new SubpanelFilterAdapter(store);
    }
    static { this.ɵfac = function SubpanelFilterAdapterFactory_Factory(t) { return new (t || SubpanelFilterAdapterFactory)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelFilterAdapterFactory, factory: SubpanelFilterAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelFilterAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelLineActionHandler extends ActionHandler {
    checkRecordAccess(data, defaultAcls = []) {
        const record = data.record ?? {};
        const acls = record.acls ?? [];
        if (!acls || !acls.length) {
            return false;
        }
        const action = data.action ?? null;
        return this.checkAccess(action, acls, defaultAcls);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessSubpanelLineAction extends SubpanelLineActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        const defaultAcls = data?.action?.acl ?? [];
        if (!defaultAcls.length) {
            return true;
        }
        return this.checkRecordAccess(data, defaultAcls);
    }
    static { this.ɵfac = function AsyncProcessSubpanelLineAction_Factory(t) { return new (t || AsyncProcessSubpanelLineAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessSubpanelLineAction, factory: AsyncProcessSubpanelLineAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessSubpanelLineAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelLineActionManager extends BaseActionManager {
    constructor(async) {
        super();
        this.async = async;
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
    }
    static { this.ɵfac = function SubpanelLineActionManager_Factory(t) { return new (t || SubpanelLineActionManager)(i0.ɵɵinject(AsyncProcessSubpanelLineAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelLineActionManager, factory: SubpanelLineActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelLineActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AsyncProcessSubpanelLineAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelLineActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    getActions(context = null) {
        return this.store.metadata$.pipe(map(metadata => metadata.lineActions)).pipe(combineLatestWith(of('list').pipe(shareReplay())), map(([actions, mode]) => {
            return this.parseModeActions(actions, mode, context);
        }));
    }
    buildActionData(action, context) {
        return {
            record: (context && context.record) || null,
            store: this.store,
            action: action
        };
    }
    getMode() {
        return 'list';
    }
    getModuleName(context) {
        return this.store.metadata.module;
    }
    reload(action, process, context) {
        this.store.load(false).pipe(take(1)).subscribe();
        this.store.loadAllStatistics(false).pipe(take(1)).subscribe();
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const metadata = this.store.metadata;
        const collectionList = metadata.collection_list || null;
        const module = (context && context.module) || moduleName;
        let linkField = metadata.get_subpanel_data;
        if (collectionList && collectionList[module] && collectionList[module].get_subpanel_data) {
            linkField = collectionList[module].get_subpanel_data;
        }
        if (linkField && action && action.params && action.params.linkFieldMapping) {
            Object.keys(action.params.linkFieldMapping).some(key => {
                if (linkField.includes(key)) {
                    linkField = action.params.linkFieldMapping[key];
                    return true;
                }
            });
        }
        return {
            action: actionName,
            module: moduleName,
            id: (context && context.record && context.record.id) || '',
            payload: {
                baseModule: this.store.parentModule,
                baseRecordId: this.store.parentId,
                linkField,
                recordModule: module,
                relateModule: this.store.metadata.module,
                relateRecordId: (context && context.record && context.record.id) || '',
            }
        };
    }
    static { this.ɵfac = function SubpanelLineActionsAdapter_Factory(t) { return new (t || SubpanelLineActionsAdapter)(i0.ɵɵinject(SubpanelStore), i0.ɵɵinject(SubpanelLineActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelLineActionsAdapter, factory: SubpanelLineActionsAdapter.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelLineActionsAdapter, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SubpanelStore }, { type: SubpanelLineActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelLineActionsAdapterFactory {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store) {
        return new SubpanelLineActionsAdapter(store, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.language, this.selectModalService, this.metadata, this.appMetadataStore);
    }
    static { this.ɵfac = function SubpanelLineActionsAdapterFactory_Factory(t) { return new (t || SubpanelLineActionsAdapterFactory)(i0.ɵɵinject(SubpanelLineActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelLineActionsAdapterFactory, factory: SubpanelLineActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelLineActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SubpanelLineActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelTableAdapter {
    constructor(store, lineActionsAdapterFactory, preferences, systemConfigs) {
        this.store = store;
        this.lineActionsAdapterFactory = lineActionsAdapterFactory;
        this.preferences = preferences;
        this.systemConfigs = systemConfigs;
    }
    getTable() {
        return {
            showHeader: false,
            showFooter: true,
            module: this.store.metadata.headerModule,
            columns: this.getColumns(),
            lineActions: this.getLineActions(),
            sort$: this.store.recordList.sort$,
            maxColumns$: of(5),
            loading$: this.store.recordList.loading$,
            dataSource: this.store.recordList,
            pagination: this.store.recordList,
            toggleRecordSelection: (id) => {
                this.store.recordList.toggleSelection(id);
            },
            updateSorting: (orderBy, sortOrder) => {
                this.store.recordList.updateSorting(orderBy, sortOrder);
                const parentModule = this.store.parentModule;
                const module = this.store.recordList.getModule();
                const sort = { orderBy, sortOrder };
                this.preferences.setUi(parentModule, module + '-subpanel-sort', sort);
            },
            maxListHeight: this.preferences.getUserPreference('subpanel_max_height') ?? this.systemConfigs.getConfigValue('subpanel_max_height'),
            paginationType: this.preferences.getUserPreference('subpanel_pagination_type') ?? this.systemConfigs.getConfigValue('subpanel_pagination_type'),
            loadMore: () => {
                const jump = this.preferences.getUserPreference('list_max_entries_per_subpanel') ?? this.systemConfigs.getConfigValue('list_max_entries_per_subpanel');
                const pagination = this.store.recordList.getPagination();
                const currentPageSize = pagination.pageSize || 0;
                const newPageSize = Number(currentPageSize) + Number(jump);
                this.store.recordList.setPageSize(newPageSize);
                this.store.recordList.updatePagination(pagination.current);
            },
            allLoaded: () => {
                const pagination = this.store.recordList.getPagination();
                if (!pagination) {
                    return false;
                }
                if (Number(pagination.pageLast) >= Number(pagination.total)) {
                    return true;
                }
                return Number(pagination.pageSize) >= Number(pagination.total);
            }
        };
    }
    getColumns() {
        return this.store.metadata$.pipe(map(metadata => metadata.columns));
    }
    getLineActions() {
        return this.lineActionsAdapterFactory.create(this.store);
    }
    static { this.ɵfac = function SubpanelTableAdapter_Factory(t) { return new (t || SubpanelTableAdapter)(i0.ɵɵinject(SubpanelStore), i0.ɵɵinject(SubpanelLineActionsAdapterFactory), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelTableAdapter, factory: SubpanelTableAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelTableAdapter, [{
        type: Injectable
    }], function () { return [{ type: SubpanelStore }, { type: SubpanelLineActionsAdapterFactory }, { type: UserPreferenceStore }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelTableAdapterFactory {
    constructor(lineActionsAdapterFactory, preferences, systemConfigs) {
        this.lineActionsAdapterFactory = lineActionsAdapterFactory;
        this.preferences = preferences;
        this.systemConfigs = systemConfigs;
    }
    create(store) {
        return new SubpanelTableAdapter(store, this.lineActionsAdapterFactory, this.preferences, this.systemConfigs);
    }
    static { this.ɵfac = function SubpanelTableAdapterFactory_Factory(t) { return new (t || SubpanelTableAdapterFactory)(i0.ɵɵinject(SubpanelLineActionsAdapterFactory), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubpanelTableAdapterFactory, factory: SubpanelTableAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelTableAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: SubpanelLineActionsAdapterFactory }, { type: UserPreferenceStore }, { type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function SubpanelComponent_scrm_list_filter_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-list-filter", 7);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("config", ctx_r0.filterConfig);
} }
class SubpanelComponent {
    constructor(actionManager, languages, tableAdapterFactory, preferences, systemConfigs, filterAdapterFactory, actionAdapterFactory) {
        this.actionManager = actionManager;
        this.languages = languages;
        this.tableAdapterFactory = tableAdapterFactory;
        this.preferences = preferences;
        this.systemConfigs = systemConfigs;
        this.filterAdapterFactory = filterAdapterFactory;
        this.actionAdapterFactory = actionAdapterFactory;
    }
    ngOnInit() {
        this.buildAdapters();
        if (this.maxColumns$) {
            this.tableConfig.maxColumns$ = this.maxColumns$;
        }
        if (this.store?.metadata?.max_height) {
            this.tableConfig.maxListHeight = this.store.metadata.max_height;
        }
        if (!this.tableConfig?.maxListHeight) {
            const ui = this.systemConfigs.getConfigValue('ui') ?? {};
            this.tableConfig.maxListHeight = ui.subpanel_max_height;
        }
        this.tableConfig.paginationType = this?.store?.metadata?.pagination_type ?? this.tableConfig.paginationType;
        const parentModule = this.store.parentModule;
        const module = this.store.recordList.getModule();
        const sort = this.preferences.getUi(parentModule, module + '-subpanel-sort');
        if (sort) {
            this.store.recordList.updateSorting(sort.orderBy, sort.sortOrder);
        }
        this.closeButton = {
            onClick: () => {
                this.onClose && this.onClose();
            }
        };
    }
    getActionContext() {
        const module = this.store?.metadata?.module ?? '';
        return { module };
    }
    buildAdapters() {
        this.adapter = this.tableAdapterFactory.create(this.store);
        this.tableConfig = this.adapter.getTable();
        this.filterAdapter = this.filterAdapterFactory.create(this.store);
        this.filterConfig = this.filterAdapter.getConfig();
        this.actionsAdapter = this.actionAdapterFactory.create(this.store);
    }
    static { this.ɵfac = function SubpanelComponent_Factory(t) { return new (t || SubpanelComponent)(i0.ɵɵdirectiveInject(SubpanelActionManager), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SubpanelTableAdapterFactory), i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(SubpanelFilterAdapterFactory), i0.ɵɵdirectiveInject(SubpanelActionAdapterFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubpanelComponent, selectors: [["scrm-subpanel"]], inputs: { store: "store", maxColumns$: "maxColumns$", onClose: "onClose", filterConfig: "filterConfig" }, features: [i0.ɵɵProvidersFeature([
                SubpanelTableAdapter
            ])], decls: 9, vars: 9, consts: [["mode", "closable", "bodyPadding", "0", 3, "title", "close", "klass"], ["panel-icon-area", "", 1, "subpanel-icon", "pl-1"], [3, "image"], ["panel-header-button", ""], ["buttonClass", "btn btn-sm btn-outline-light", 3, "config", "actionContext", "actionLimitConfig"], ["panel-body", ""], [3, "config", 4, "ngIf"], [3, "config"]], template: function SubpanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementContainerStart(0);
            i0.ɵɵelementStart(1, "scrm-panel", 0)(2, "span", 1);
            i0.ɵɵelement(3, "scrm-image", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(4, "span", 3);
            i0.ɵɵelement(5, "scrm-action-group-menu", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 5);
            i0.ɵɵtemplate(7, SubpanelComponent_scrm_list_filter_7_Template, 1, 1, "scrm-list-filter", 6);
            i0.ɵɵelement(8, "scrm-table", 7);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementContainerEnd();
        } if (rf & 2) {
            let tmp_2_0;
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("title", ctx.store.getTitle())("close", ctx.closeButton)("klass", (tmp_2_0 = "subpanel-" + (ctx.store == null ? null : ctx.store.metadata == null ? null : ctx.store.metadata.name)) !== null && tmp_2_0 !== undefined ? tmp_2_0 : "");
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("image", ctx.store.getIcon());
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("config", ctx.actionsAdapter)("actionContext", ctx.getActionContext())("actionLimitConfig", "subpanelview_actions_limits");
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.store.showFilter);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("config", ctx.tableConfig);
        } }, dependencies: [i2.NgIf, ImageComponent, PanelComponent, TableComponent, ListFilterComponent, ActionGroupMenuComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-subpanel', providers: [
                    SubpanelTableAdapter
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container>\n    <scrm-panel [title]=\"store.getTitle()\" mode=\"closable\" [close]=\"closeButton\" bodyPadding=\"0\" [klass]=\"'subpanel-' + store?.metadata?.name ?? ''\">\n        <span class=\"subpanel-icon pl-1\" panel-icon-area>\n            <scrm-image [image]=\"store.getIcon()\"></scrm-image>\n        </span>\n        <span panel-header-button>\n            <scrm-action-group-menu [config]=\"actionsAdapter\"\n                                    [actionContext]=\"getActionContext()\"\n                                    [actionLimitConfig]=\"'subpanelview_actions_limits'\"\n                                    buttonClass=\"btn btn-sm btn-outline-light\"\n            ></scrm-action-group-menu>\n        </span>\n        <div panel-body>\n            <scrm-list-filter *ngIf=\"store.showFilter\" [config]=\"filterConfig\"></scrm-list-filter>\n            <scrm-table [config]=\"tableConfig\"></scrm-table>\n        </div>\n    </scrm-panel>\n</ng-container>\n" }]
    }], function () { return [{ type: SubpanelActionManager }, { type: LanguageStore }, { type: SubpanelTableAdapterFactory }, { type: UserPreferenceStore }, { type: SystemConfigStore }, { type: SubpanelFilterAdapterFactory }, { type: SubpanelActionAdapterFactory }]; }, { store: [{
            type: Input
        }], maxColumns$: [{
            type: Input
        }], onClose: [{
            type: Input
        }], filterConfig: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelModule {
    static { this.ɵfac = function SubpanelModule_Factory(t) { return new (t || SubpanelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SubpanelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgbModule,
            ImageModule,
            PanelModule,
            RouterModule,
            ButtonGroupModule,
            TableModule,
            ListFilterModule,
            ActionGroupMenuModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelModule, [{
        type: NgModule,
        args: [{
                declarations: [SubpanelComponent],
                exports: [SubpanelComponent],
                imports: [
                    CommonModule,
                    NgbModule,
                    ImageModule,
                    PanelModule,
                    RouterModule,
                    ButtonGroupModule,
                    TableModule,
                    ListFilterModule,
                    ActionGroupMenuModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SubpanelModule, { declarations: [SubpanelComponent], imports: [CommonModule,
        NgbModule,
        ImageModule,
        PanelModule,
        RouterModule,
        ButtonGroupModule,
        TableModule,
        ListFilterModule,
        ActionGroupMenuModule], exports: [SubpanelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function SubpanelContainerComponent_ng_container_0_ng_container_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-image", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("image", ctx_r3.toggleIcon());
    i0.ɵɵattribute("aria-expanded", false);
} }
function SubpanelContainerComponent_ng_container_0_ng_container_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-image", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("image", ctx_r4.toggleIcon());
    i0.ɵɵattribute("aria-expanded", true);
} }
const _c0$5 = function (a0) { return { "sub-panel-banner-button-active": a0 }; };
function SubpanelContainerComponent_ng_container_0_ng_template_12_div_2_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 16);
    i0.ɵɵlistener("click", function SubpanelContainerComponent_ng_container_0_ng_template_12_div_2_Template_div_click_0_listener() { const restoredCtx = i0.ɵɵrestoreView(_r10); const item_r8 = restoredCtx.$implicit; const ctx_r9 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r9.showSubpanel(item_r8.key, item_r8.value)); });
    i0.ɵɵelement(1, "scrm-grid-widget", 17);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r8 = ctx.$implicit;
    const ctx_r7 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(2, _c0$5, item_r8.value.show === true));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r7.getGridConfig(item_r8.value));
} }
function SubpanelContainerComponent_ng_container_0_ng_template_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13)(1, "div", 14);
    i0.ɵɵtemplate(2, SubpanelContainerComponent_ng_container_0_ng_template_12_div_2_Template, 2, 4, "div", 15);
    i0.ɵɵpipe(3, "keyvalue");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(3, 1, vm_r1.subpanels));
} }
function SubpanelContainerComponent_ng_container_0_ng_container_14_ng_container_1_scrm_subpanel_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-subpanel", 19);
} if (rf & 2) {
    const item_r14 = i0.ɵɵnextContext().ngIf;
    const subpanelKey_r12 = i0.ɵɵnextContext().$implicit;
    const ctx_r15 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("maxColumns$", ctx_r15.maxColumns$)("store", item_r14)("filterConfig", ctx_r15.filterConfig)("onClose", ctx_r15.getCloseCallBack(subpanelKey_r12, item_r14));
} }
function SubpanelContainerComponent_ng_container_0_ng_container_14_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, SubpanelContainerComponent_ng_container_0_ng_container_14_ng_container_1_scrm_subpanel_1_Template, 1, 4, "scrm-subpanel", 18);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r14 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r14.show);
} }
function SubpanelContainerComponent_ng_container_0_ng_container_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, SubpanelContainerComponent_ng_container_0_ng_container_14_ng_container_1_Template, 2, 1, "ng-container", 0);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const subpanelKey_r12 = ctx.$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.subpanels[subpanelKey_r12]);
} }
function SubpanelContainerComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 1, 2)(3, "div", 3)(4, "div", 4)(5, "a", 5);
    i0.ɵɵlistener("click", function SubpanelContainerComponent_ng_container_0_Template_a_click_5_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r19.toggleSubPanels()); });
    i0.ɵɵelementStart(6, "div", 6);
    i0.ɵɵelement(7, "scrm-label", 7);
    i0.ɵɵtemplate(8, SubpanelContainerComponent_ng_container_0_ng_container_8_Template, 2, 2, "ng-container", 0);
    i0.ɵɵtemplate(9, SubpanelContainerComponent_ng_container_0_ng_container_9_Template, 2, 2, "ng-container", 0);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(10, "div", 8)(11, "div", 9);
    i0.ɵɵtemplate(12, SubpanelContainerComponent_ng_container_0_ng_template_12_Template, 4, 3, "ng-template");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(13, "div", 10);
    i0.ɵɵtemplate(14, SubpanelContainerComponent_ng_container_0_ng_container_14_Template, 2, 1, "ng-container", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("collapsed", ctx_r0.isCollapsed());
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r0.isCollapsed());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.isCollapsed());
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngForOf", ctx_r0.openSubpanels);
} }
class SubpanelContainerComponent {
    constructor(languageStore, maxColumnCalculator, localStorage, preferences) {
        this.languageStore = languageStore;
        this.maxColumnCalculator = maxColumnCalculator;
        this.localStorage = localStorage;
        this.preferences = preferences;
        this.isCollapsed = signal(false);
        this.toggleIcon = signal('arrow_down_filled');
        this.languages$ = this.languageStore.vm$;
        this.openSubpanels = [];
    }
    ngOnInit() {
        const module = this?.config?.parentModule ?? 'default';
        this.setCollapsed(isTrue(this.preferences.getUi(module, 'subpanel-container-collapse') ?? false));
        this.openSubpanels = this.preferences.getUi(module, 'subpanel-container-open-subpanels') ?? [];
        this.vm$ = this.config.subpanels$.pipe(map((subpanelsMap) => ({
            subpanels: subpanelsMap
        })), tap((subpanelsMap) => {
            if (!subpanelsMap || !Object.keys(subpanelsMap).length) {
                return;
            }
            if (!this.openSubpanels || this.openSubpanels.length < 1) {
                return;
            }
            this.openSubpanels.forEach(subpanelKey => {
                const subpanel = subpanelsMap.subpanels[subpanelKey];
                if (!subpanel || subpanel.show) {
                    return;
                }
                subpanel.show = true;
                subpanel.load().pipe(take(1)).subscribe();
            });
        }));
        this.maxColumns$ = this.getMaxColumns();
    }
    getMaxColumns() {
        return this.maxColumnCalculator.getMaxColumns(this.config.sidebarActive$);
    }
    toggleSubPanels() {
        this.setCollapsed(!this.isCollapsed());
        const module = this?.config?.parentModule ?? 'default';
        this.preferences.setUi(module, 'subpanel-container-collapse', this.isCollapsed());
    }
    showSubpanel(key, item) {
        item.show = !item.show;
        if (item.show) {
            if (!this.openSubpanels.includes(key)) {
                this.openSubpanels.push(key);
            }
            item.load().pipe(take(1)).subscribe();
        }
        else {
            this.openSubpanels = this.openSubpanels.filter(subpanelKey => subpanelKey != key);
        }
        const module = this?.config?.parentModule ?? 'default';
        this.preferences.setUi(module, 'subpanel-container-open-subpanels', this.openSubpanels);
    }
    getCloseCallBack(key, item) {
        return () => this.showSubpanel(key, item);
    }
    getGridConfig(vm) {
        if (!vm.metadata || !vm.metadata.insightWidget) {
            return {
                layout: null,
            };
        }
        const layout = vm.getWidgetLayout();
        layout.rows.forEach(row => {
            if (!row.cols || !row.cols.length) {
                return;
            }
            row.cols.forEach(col => {
                if (!col.statistic) {
                    return;
                }
                const store = vm.getStatistic(col.statistic);
                if (store) {
                    col.store = store;
                }
            });
        });
        return {
            rowClass: 'statistics-sidebar-widget-row',
            columnClass: 'statistics-sidebar-widget-col',
            layout,
            widgetConfig: {},
            queryArgs: {
                module: vm.metadata.name,
                context: { module: vm.parentModule, id: vm.parentId },
                params: { subpanel: vm.metadata.name },
            },
        };
    }
    setCollapsed(newCollapsedValue) {
        this.isCollapsed.set(newCollapsedValue);
        this.setToggleIcon();
    }
    setToggleIcon() {
        this.toggleIcon.set((this.isCollapsed()) ? 'arrow_up_filled' : 'arrow_down_filled');
    }
    static { this.ɵfac = function SubpanelContainerComponent_Factory(t) { return new (t || SubpanelContainerComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(MaxColumnsCalculator), i0.ɵɵdirectiveInject(LocalStorageService), i0.ɵɵdirectiveInject(UserPreferenceStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubpanelContainerComponent, selectors: [["scrm-subpanel-container"]], inputs: { config: "config" }, features: [i0.ɵɵProvidersFeature([MaxColumnsCalculator])], decls: 2, vars: 3, consts: [[4, "ngIf"], ["ngbAccordion", "", "activeIds", "sub-panel-buttons", 1, "sub-panel-banner"], ["accordion", "ngbAccordion"], ["ngbAccordionItem", "", "id", "sub-panel-buttons", 1, "card", 3, "collapsed"], ["ngbAccordionHeader", "", 1, "card-header"], [1, "clickable", 3, "click"], [1, "d-flex", "align-items-center", "justify-content-between"], ["labelKey", "LBL_SELECT_SUBPANEL_BANNER"], ["ngbAccordionCollapse", ""], ["ngbAccordionBody", ""], ["id", "sub-panels"], [4, "ngFor", "ngForOf"], ["aria-controls", "collapseShowSubPanels", 1, "float-right", 3, "image"], ["id", "collapseShowSubPanels"], [1, "row", "insight-panel"], ["class", "col-xs-6 col-sm-3 col-md-2 insight-panel-card border-insight", 3, "ngClass", "click", 4, "ngFor", "ngForOf"], [1, "col-xs-6", "col-sm-3", "col-md-2", "insight-panel-card", "border-insight", 3, "ngClass", "click"], [3, "config"], ["class", "sub-panel", 3, "maxColumns$", "store", "filterConfig", "onClose", 4, "ngIf"], [1, "sub-panel", 3, "maxColumns$", "store", "filterConfig", "onClose"]], template: function SubpanelContainerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, SubpanelContainerComponent_ng_container_0_Template, 15, 4, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i3$1.NgbAccordionDirective, i3$1.NgbAccordionItem, i3$1.NgbAccordionHeader, i3$1.NgbAccordionBody, i3$1.NgbAccordionCollapse, ImageComponent, SubpanelComponent, GridWidgetComponent, LabelComponent, i2.AsyncPipe, i2.KeyValuePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelContainerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-subpanel-container', providers: [MaxColumnsCalculator], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n    <div ngbAccordion class=\"sub-panel-banner\" #accordion=\"ngbAccordion\" activeIds=\"sub-panel-buttons\">\n        <div ngbAccordionItem id=\"sub-panel-buttons\" class=\"card\" [collapsed]=\"isCollapsed()\">\n            <div ngbAccordionHeader class=\"card-header\">\n                <a (click)=\"toggleSubPanels()\" class=\"clickable\">\n                    <div class=\"d-flex align-items-center justify-content-between\">\n                        <scrm-label labelKey=\"LBL_SELECT_SUBPANEL_BANNER\"></scrm-label>\n                        <ng-container *ngIf=\"isCollapsed()\">\n                            <scrm-image\n                                    [attr.aria-expanded]=\"false\"\n                                    [image]=\"toggleIcon()\"\n                                    aria-controls=\"collapseShowSubPanels\"\n                                    class=\"float-right\">\n                            </scrm-image>\n                        </ng-container>\n                        <ng-container *ngIf=\"!isCollapsed()\">\n                            <scrm-image\n                                    [attr.aria-expanded]=\"true\"\n                                    [image]=\"toggleIcon()\"\n                                    aria-controls=\"collapseShowSubPanels\"\n                                    class=\"float-right\">\n                            </scrm-image>\n                        </ng-container>\n                    </div>\n                </a>\n            </div>\n            <div ngbAccordionCollapse>\n                <div ngbAccordionBody>\n                    <ng-template>\n                        <div id=\"collapseShowSubPanels\">\n                            <div class=\"row insight-panel\">\n                                <div class=\"col-xs-6 col-sm-3 col-md-2 insight-panel-card border-insight\"\n                                     *ngFor=\"let item of vm.subpanels | keyvalue\"\n                                     [ngClass]=\"{'sub-panel-banner-button-active': item.value.show === true}\"\n                                     (click)=\"showSubpanel(item.key, item.value)\">\n                                    <scrm-grid-widget [config]=\"getGridConfig(item.value)\"></scrm-grid-widget>\n\n                                </div>\n                            </div>\n                        </div>\n                    </ng-template>\n                </div>\n            </div>\n\n        </div>\n    </div>\n\n    <div id=\"sub-panels\">\n        <ng-container *ngFor=\"let subpanelKey of this.openSubpanels\">\n            <ng-container *ngIf=\"(vm.subpanels[subpanelKey]) as item\">\n                <scrm-subpanel *ngIf=\"item.show\"\n                               [maxColumns$]=\"maxColumns$\"\n                               [store]=\"item\"\n                               [filterConfig]=\"filterConfig\"\n                               [onClose]=\"getCloseCallBack(subpanelKey, item)\"\n                               class=\"sub-panel\">\n                </scrm-subpanel>\n            </ng-container>\n        </ng-container>\n\n    </div>\n\n</ng-container>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: MaxColumnsCalculator }, { type: LocalStorageService }, { type: UserPreferenceStore }]; }, { config: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SubpanelContainerModule {
    static { this.ɵfac = function SubpanelContainerModule_Factory(t) { return new (t || SubpanelContainerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: SubpanelContainerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            NgbModule,
            ImageModule,
            RouterModule,
            SubpanelModule,
            InlineLoadingSpinnerModule,
            FieldModule,
            GridWidgetModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubpanelContainerModule, [{
        type: NgModule,
        args: [{
                declarations: [SubpanelContainerComponent],
                exports: [SubpanelContainerComponent],
                imports: [
                    CommonModule,
                    NgbModule,
                    ImageModule,
                    RouterModule,
                    SubpanelModule,
                    InlineLoadingSpinnerModule,
                    FieldModule,
                    GridWidgetModule,
                    LabelModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(SubpanelContainerModule, { declarations: [SubpanelContainerComponent], imports: [CommonModule,
        NgbModule,
        ImageModule,
        RouterModule,
        SubpanelModule,
        InlineLoadingSpinnerModule,
        FieldModule,
        GridWidgetModule,
        LabelModule], exports: [SubpanelContainerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function StatisticsTopWidgetComponent_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 4);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "uppercase");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, vm_r1.appStrings[ctx_r2.messageLabelKey] || ""), " ");
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "uppercase");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r11 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, ctx_r11.getLabel(item_r5.value.labelKey)), ": ");
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "uppercase");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(3).$implicit;
    const ctx_r12 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, ctx_r12.getLabel(item_r5.value.labelKey)), " ");
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_ng_container_1_Template, 3, 3, "ng-container", 6);
    i0.ɵɵtemplate(2, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_ng_container_2_Template, 3, 3, "ng-container", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(2).$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r10 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r10.isValueEmpty(vm_r1.statistics[item_r5.key]));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r10.isValueEmpty(vm_r1.statistics[item_r5.key]));
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_div_1_Template, 3, 2, "div", 8);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext().$implicit;
    const ctx_r6 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r5.value.labelKey && ctx_r6.getLabel(item_r5.value.labelKey));
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_div_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-field", 12);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(3).$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("type", vm_r1.statistics[item_r5.key].field.type)("field", vm_r1.statistics[item_r5.key].field);
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_div_1_ng_container_1_Template, 2, 2, "ng-container", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(2).$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r18 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r18.isValueEmpty(vm_r1.statistics[item_r5.key]) || item_r5.value.hideValueIfEmpty !== true);
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_div_1_Template, 2, 1, "div", 10);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext().$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !vm_r1.statistics[item_r5.key].loading && vm_r1.statistics[item_r5.key].field);
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_div_4_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1, " - ");
    i0.ɵɵelementContainerEnd();
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵelement(1, "scrm-inline-loading-spinner");
    i0.ɵɵtemplate(2, StatisticsTopWidgetComponent_div_0_ng_container_2_div_4_ng_container_2_Template, 2, 0, "ng-container", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const loading_r26 = ctx.ngIf;
    const item_r5 = i0.ɵɵnextContext().$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !loading_r26 && (!item_r5.key || !vm_r1.statistics[item_r5.key]));
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_6_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "uppercase");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r30 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, ctx_r30.getLabel(item_r5.value.endLabelKey)), " ");
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_6_div_1_Template, 3, 3, "div", 14);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = i0.ɵɵnextContext().$implicit;
    const ctx_r9 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r5.value.endLabelKey && ctx_r9.getLabel(item_r5.value.endLabelKey));
} }
function StatisticsTopWidgetComponent_div_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 5);
    i0.ɵɵtemplate(2, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_2_Template, 2, 1, "ng-container", 6);
    i0.ɵɵtemplate(3, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_3_Template, 2, 1, "ng-container", 6);
    i0.ɵɵtemplate(4, StatisticsTopWidgetComponent_div_0_ng_container_2_div_4_Template, 3, 1, "div", 7);
    i0.ɵɵpipe(5, "async");
    i0.ɵɵtemplate(6, StatisticsTopWidgetComponent_div_0_ng_container_2_ng_container_6_Template, 2, 1, "ng-container", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r5 = ctx.$implicit;
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !ctx_r3.shouldHide(vm_r1.statistics[item_r5.key], item_r5.value));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r5.key && vm_r1.statistics[item_r5.key] && !ctx_r3.shouldHide(vm_r1.statistics[item_r5.key], item_r5.value));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(5, 4, item_r5.value.store.loading$));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !ctx_r3.shouldHide(vm_r1.statistics[item_r5.key], item_r5.value));
} }
function StatisticsTopWidgetComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, StatisticsTopWidgetComponent_div_0_div_1_Template, 3, 3, "div", 2);
    i0.ɵɵtemplate(2, StatisticsTopWidgetComponent_div_0_ng_container_2_Template, 7, 6, "ng-container", 3);
    i0.ɵɵpipe(3, "keyvalue");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.messageLabelKey);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(3, 2, ctx_r0.statistics));
} }
class StatisticsTopWidgetComponent extends BaseWidgetComponent {
    constructor(language, factory) {
        super();
        this.language = language;
        this.factory = factory;
        this.statistics = {};
        this.loading = true;
        this.subs = [];
    }
    ngOnInit() {
        if (!this.context || !this.context.module) {
            this.messageLabelKey = 'LBL_CONFIG_BAD_CONTEXT';
            return;
        }
        if (!this.config) {
            this.messageLabelKey = 'LBL_CONFIG_NO_CONFIG';
            return;
        }
        if (!this.config.options || !this.config.options.statistics || !this.config.options.statistics.length) {
            this.messageLabelKey = 'LBL_CONFIG_NO_STATISTICS_KEY';
            return;
        }
        if (this.context$) {
            this.subs.push(this.context$.subscribe((context) => {
                this.context = context;
            }));
        }
        const statistics$ = [];
        const loadings$ = [];
        this.config.options.statistics.forEach(statistic => {
            if (!statistic.type) {
                return;
            }
            this.statistics[statistic.type] = {
                labelKey: statistic.labelKey || '',
                endLabelKey: statistic.endLabelKey || '',
                hideValueIfEmpty: statistic.hideValueIfEmpty || false,
                type: statistic.type,
                store: this.factory.create()
            };
            this.statistics[statistic.type].store.init(this.context.module, {
                key: statistic.type,
                context: { ...this.context }
            }).pipe(take(1)).subscribe();
            statistics$.push(this.statistics[statistic.type].store.state$);
            loadings$.push(this.statistics[statistic.type].store.loading$);
        });
        let statisticObs = null;
        if (statistics$.length < 1) {
            statisticObs = of([]);
        }
        else if (statistics$.length === 1) {
            statisticObs = statistics$[0].pipe(map(value => [value]));
        }
        else {
            let firsObs = null;
            let others;
            [firsObs, ...others] = statistics$;
            statisticObs = firsObs.pipe(combineLatestWith(others));
        }
        this.loading$ = loadings$[0].pipe(combineLatestWith(...loadings$), map((loadings) => {
            if (!loadings || loadings.length < 1) {
                this.loading = false;
                return false;
            }
            let loading = true;
            loadings.forEach(value => {
                loading = loading && value;
            });
            this.loading = loading;
            return loading;
        }));
        this.subs.push(this.loading$.subscribe());
        this.vm$ = statisticObs.pipe(combineLatestWith(this.language.appStrings$), map(([statistics, appStrings]) => {
            const statsMap = {};
            statistics.forEach(value => {
                statsMap[value.query.key] = value;
                this.statistics[value.query.key].labelKey = this.getMetadataEntry(value, 'labelKey');
                this.statistics[value.query.key].endLabelKey = this.getMetadataEntry(value, 'endLabelKey');
            });
            return {
                statistics: statsMap,
                appStrings
            };
        }));
        if (this.config.reload$) {
            this.subs.push(this.config.reload$.subscribe(() => {
                if (this.loading === false) {
                    this.loading = true;
                    this.config.options.statistics.forEach(statistic => {
                        if (!statistic.type) {
                            return;
                        }
                        if (!this.statistics[statistic.type] || !this.statistics[statistic.type].store) {
                            return;
                        }
                        this.statistics[statistic.type].store.load(false).pipe(take(1)).subscribe();
                    });
                }
            }));
        }
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    /**
     * Check if statistics should be hidden
     * @param stats
     * @param item
     */
    shouldHide(stats, item) {
        return this.hasLoaded(stats) && this.isValueEmpty(stats) && item.hideIfEmpty === true;
    }
    /**
     * Check if statistics have been loaded
     * @param stats
     */
    hasLoaded(stats) {
        return !stats.loading;
    }
    /**
     * Check if value is empty
     * @param stats
     */
    isValueEmpty(stats) {
        const emptyValue = stats?.statistic?.metadata?.emptyValueString ?? null;
        if (emptyValue !== null) {
            return true;
        }
        const value = stats?.field?.value ?? null;
        if (value) {
            return false;
        }
        return emptyValue === value;
    }
    /**
     * Get metadata entry for statistic
     * @param stat
     * @param name
     */
    getMetadataEntry(stat, name) {
        const value = stat.statistic.metadata && stat.statistic.metadata[name];
        if (value !== null && typeof value !== 'undefined') {
            return value;
        }
        return this.statistics[stat.query.key][name];
    }
    /**
     * Get label value
     * @param key
     */
    getLabel(key) {
        const context = this.context || {};
        const module = context.module || '';
        return this.language.getFieldLabel(key, module);
    }
    static { this.ɵfac = function StatisticsTopWidgetComponent_Factory(t) { return new (t || StatisticsTopWidgetComponent)(i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(SingleValueStatisticsStoreFactory)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StatisticsTopWidgetComponent, selectors: [["scrm-statistics-top-widget"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [["class", "d-sm-flex justify-content-center widget-bar rounded", 4, "ngIf"], [1, "d-sm-flex", "justify-content-center", "widget-bar", "rounded"], ["class", "p-2 widget-bar-entry-message", 4, "ngIf"], [4, "ngFor", "ngForOf"], [1, "p-2", "widget-bar-entry-message"], [1, "d-flex", "justify-content-center", "align-items-baseline", "widget-bar-entry", "p-2"], [4, "ngIf"], ["class", "pl-1 pr-1 widget-bar-entry-loading", 4, "ngIf"], ["class", "pr-1 widget-bar-entry-label", 4, "ngIf"], [1, "pr-1", "widget-bar-entry-label"], ["class", "pl-1 pr-1 widget-bar-entry-value", 4, "ngIf"], [1, "pl-1", "pr-1", "widget-bar-entry-value"], ["mode", "list", 3, "type", "field"], [1, "pl-1", "pr-1", "widget-bar-entry-loading"], ["class", "pl-1 widget-bar-entry-end-label", 4, "ngIf"], [1, "pl-1", "widget-bar-entry-end-label"]], template: function StatisticsTopWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, StatisticsTopWidgetComponent_div_0_Template, 4, 4, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgForOf, i2.NgIf, FieldComponent, InlineLoadingSpinnerComponent, i2.AsyncPipe, i2.UpperCasePipe, i2.KeyValuePipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsTopWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-statistics-top-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"(vm$ | async) as vm\"\n     class=\"d-sm-flex justify-content-center widget-bar rounded\">\n    <div class=\"p-2 widget-bar-entry-message\" *ngIf=\"this.messageLabelKey\">\n        {{vm.appStrings[this.messageLabelKey] || '' | uppercase}}\n    </div>\n    <ng-container *ngFor=\"let item of statistics | keyvalue\">\n\n        <div class=\"d-flex justify-content-center align-items-baseline widget-bar-entry p-2\">\n\n            <ng-container *ngIf=\"!shouldHide(vm.statistics[item.key], item.value)\">\n\n                <div *ngIf=\"item.value.labelKey && getLabel(item.value.labelKey)\" class=\"pr-1 widget-bar-entry-label\">\n                    <ng-container *ngIf=\"!isValueEmpty(vm.statistics[item.key])\">\n                        {{getLabel(item.value.labelKey) | uppercase}}:\n                    </ng-container>\n                    <ng-container *ngIf=\"isValueEmpty(vm.statistics[item.key])\">\n                        {{getLabel(item.value.labelKey) | uppercase}}\n                    </ng-container>\n                </div>\n\n            </ng-container>\n\n            <ng-container\n                *ngIf=\"item.key && vm.statistics[item.key] && !shouldHide(vm.statistics[item.key], item.value)\">\n\n                <div class=\"pl-1 pr-1 widget-bar-entry-value\"\n                     *ngIf=\"!vm.statistics[item.key].loading && vm.statistics[item.key].field\">\n                    <ng-container\n                        *ngIf=\"!isValueEmpty(vm.statistics[item.key]) || item.value.hideValueIfEmpty !== true\">\n                        <scrm-field [type]=\"vm.statistics[item.key].field.type\" [field]=\"vm.statistics[item.key].field\"\n                                    mode=\"list\"></scrm-field>\n\n                    </ng-container>\n                </div>\n\n            </ng-container>\n\n            <div class=\"pl-1 pr-1 widget-bar-entry-loading\" *ngIf=\"(item.value.store.loading$ | async) as loading\">\n                <scrm-inline-loading-spinner></scrm-inline-loading-spinner>\n\n                <ng-container *ngIf=\"!loading && (!item.key || !vm.statistics[item.key])\">\n                    -\n                </ng-container>\n            </div>\n\n            <ng-container *ngIf=\"!shouldHide(vm.statistics[item.key], item.value)\">\n\n                <div *ngIf=\"item.value.endLabelKey && getLabel(item.value.endLabelKey)\"\n                     class=\"pl-1 widget-bar-entry-end-label\">\n                    {{getLabel(item.value.endLabelKey) | uppercase}}\n                </div>\n\n            </ng-container>\n\n        </div>\n\n    </ng-container>\n</div>\n" }]
    }], function () { return [{ type: LanguageStore }, { type: SingleValueStatisticsStoreFactory }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsTopWidgetModule {
    static { this.ɵfac = function StatisticsTopWidgetModule_Factory(t) { return new (t || StatisticsTopWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: StatisticsTopWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            InlineLoadingSpinnerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsTopWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [StatisticsTopWidgetComponent],
                exports: [
                    StatisticsTopWidgetComponent
                ],
                imports: [
                    CommonModule,
                    FieldModule,
                    InlineLoadingSpinnerModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(StatisticsTopWidgetModule, { declarations: [StatisticsTopWidgetComponent], imports: [CommonModule,
        FieldModule,
        InlineLoadingSpinnerModule], exports: [StatisticsTopWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const topWidgetModules = [
    StatisticsTopWidgetModule,
];
const topWidgetComponentTypeMap = {
    statistics: StatisticsTopWidgetComponent,
};

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$4 = function (a0, a1) { return { "config": a0, "context": a1 }; };
function TopWidgetComponent_ndc_dynamic_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ndc-dynamic", 1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ndcDynamicComponent", ctx_r0.componentType)("ndcDynamicInputs", i0.ɵɵpureFunction2(2, _c0$4, ctx_r0.config, ctx_r0.context));
} }
class TopWidgetComponent extends BaseWidgetComponent {
    constructor() {
        super(...arguments);
        this.map = topWidgetComponentTypeMap;
    }
    get componentType() {
        return this.map[this.type];
    }
    ngOnInit() {
        this.component = this.componentType;
        this.inputs = {
            'config': this.config,
            'context': this.context
        };
    }
    static { this.ɵfac = /*@__PURE__*/ function () { let ɵTopWidgetComponent_BaseFactory; return function TopWidgetComponent_Factory(t) { return (ɵTopWidgetComponent_BaseFactory || (ɵTopWidgetComponent_BaseFactory = i0.ɵɵgetInheritedFactory(TopWidgetComponent)))(t || TopWidgetComponent); }; }(); }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TopWidgetComponent, selectors: [["scrm-top-widget"]], inputs: { type: "type" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "ndcDynamicComponent", "ndcDynamicInputs", 4, "ngIf"], [3, "ndcDynamicComponent", "ndcDynamicInputs"]], template: function TopWidgetComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, TopWidgetComponent_ndc_dynamic_0_Template, 1, 5, "ndc-dynamic", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.type && ctx.config);
        } }, dependencies: [i2.NgIf, i3$3.DynamicIoDirective, i3$3.DynamicComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TopWidgetComponent, [{
        type: Component,
        args: [{ selector: 'scrm-top-widget', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ndc-dynamic *ngIf=\"type && config\"\n             [ndcDynamicComponent]=\"componentType\"\n             [ndcDynamicInputs]=\"{\n        'config': config,\n        'context': context\n    }\"\n></ndc-dynamic>\n" }]
    }], null, { type: [{
            type: Input,
            args: ['type']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TopWidgetModule {
    static { this.ɵfac = function TopWidgetModule_Factory(t) { return new (t || TopWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TopWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule, topWidgetModules, DynamicModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TopWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [TopWidgetComponent],
                exports: [TopWidgetComponent],
                imports: [
                    CommonModule,
                    ...topWidgetModules,
                    DynamicModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TopWidgetModule, { declarations: [TopWidgetComponent], imports: [CommonModule, StatisticsTopWidgetModule, DynamicModule], exports: [TopWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseWidgetModule {
    static { this.ɵfac = function BaseWidgetModule_Factory(t) { return new (t || BaseWidgetModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BaseWidgetModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            DynamicModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseWidgetModule, [{
        type: NgModule,
        args: [{
                declarations: [BaseWidgetComponent],
                exports: [BaseWidgetComponent],
                imports: [
                    CommonModule,
                    DynamicModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BaseWidgetModule, { declarations: [BaseWidgetComponent], imports: [CommonModule,
        DynamicModule], exports: [BaseWidgetComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ButtonLoadingDirective {
    constructor(el, appStateStore) {
        this.el = el;
        this.appStateStore = appStateStore;
        this.appLoading = false;
    }
    ngOnInit() {
        this.subscription = this.appStateStore.loading$.pipe(tap((loading) => {
            this.appLoading = loading;
            this.updateComponent();
        })).subscribe();
        this.updateComponent();
    }
    ngOnChanges(changes) {
        if (changes.state) {
            this.updateComponent();
        }
    }
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
    clickEvent() {
        this.updateComponent();
    }
    /**
     * Calculate loading state and update loading
     */
    updateComponent() {
        const loading = this.isLoading();
        this.setDisabledState(loading);
    }
    /**
     * Calculate if is loading
     *
     * @returns {boolean} isLoading
     */
    isLoading() {
        let loading = false;
        if (this.state === true || this.appLoading === true) {
            loading = true;
        }
        return loading;
    }
    /**
     * Disable or enable button
     *
     * @param {boolean} state to set
     */
    setDisabledState(state) {
        this.el.nativeElement.disabled = state;
    }
    static { this.ɵfac = function ButtonLoadingDirective_Factory(t) { return new (t || ButtonLoadingDirective)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(AppStateStore)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ButtonLoadingDirective, selectors: [["", "scrm-button-loading", ""]], hostBindings: function ButtonLoadingDirective_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("click", function ButtonLoadingDirective_click_HostBindingHandler() { return ctx.clickEvent(); });
        } }, inputs: { state: ["scrm-button-loading", "state"] }, features: [i0.ɵɵNgOnChangesFeature] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonLoadingDirective, [{
        type: Directive,
        args: [{
                selector: '[scrm-button-loading]'
            }]
    }], function () { return [{ type: i0.ElementRef }, { type: AppStateStore }]; }, { state: [{
            type: Input,
            args: ['scrm-button-loading']
        }], clickEvent: [{
            type: HostListener,
            args: ['click']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ButtonLoadingUiModule {
    static { this.ɵfac = function ButtonLoadingUiModule_Factory(t) { return new (t || ButtonLoadingUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ButtonLoadingUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ButtonLoadingUiModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    ButtonLoadingDirective
                ],
                exports: [
                    ButtonLoadingDirective
                ],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ButtonLoadingUiModule, { declarations: [ButtonLoadingDirective], imports: [CommonModule], exports: [ButtonLoadingDirective] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseFieldModule {
    static { this.ɵfac = function BaseFieldModule_Factory(t) { return new (t || BaseFieldModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BaseFieldModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseFieldModule, [{
        type: NgModule,
        args: [{
                exports: [
                    BaseBooleanComponent,
                    BaseEnumComponent,
                    BaseFieldComponent,
                    BaseMultiEnumComponent,
                    BaseNameComponent,
                    BaseNumberComponent,
                    BaseRelateComponent,
                    BaseDateTimeComponent,
                    BaseDateComponent
                ],
                declarations: [
                    BaseBooleanComponent,
                    BaseEnumComponent,
                    BaseFieldComponent,
                    BaseMultiEnumComponent,
                    BaseNameComponent,
                    BaseNumberComponent,
                    BaseRelateComponent,
                    BaseDateTimeComponent,
                    BaseDateComponent
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(BaseFieldModule, { declarations: [BaseBooleanComponent,
        BaseEnumComponent,
        BaseFieldComponent,
        BaseMultiEnumComponent,
        BaseNameComponent,
        BaseNumberComponent,
        BaseRelateComponent,
        BaseDateTimeComponent,
        BaseDateComponent], imports: [CommonModule], exports: [BaseBooleanComponent,
        BaseEnumComponent,
        BaseFieldComponent,
        BaseMultiEnumComponent,
        BaseNameComponent,
        BaseNumberComponent,
        BaseRelateComponent,
        BaseDateTimeComponent,
        BaseDateComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EmailDetailFieldsComponent extends BaseFieldComponent {
    constructor(typeFormatter, logic, logicDisplay) {
        super(typeFormatter, logic, logicDisplay);
        this.typeFormatter = typeFormatter;
        this.logic = logic;
        this.logicDisplay = logicDisplay;
    }
    static { this.ɵfac = function EmailDetailFieldsComponent_Factory(t) { return new (t || EmailDetailFieldsComponent)(i0.ɵɵdirectiveInject(DataTypeFormatter), i0.ɵɵdirectiveInject(FieldLogicManager), i0.ɵɵdirectiveInject(FieldLogicDisplayManager)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EmailDetailFieldsComponent, selectors: [["scrm-email-detail"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, template: function EmailDetailFieldsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtext(0);
        } if (rf & 2) {
            i0.ɵɵtextInterpolate1("\n", ctx.field.value, "\n");
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailDetailFieldsComponent, [{
        type: Component,
        args: [{ selector: 'scrm-email-detail', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n{{ field.value }}\n" }]
    }], function () { return [{ type: DataTypeFormatter }, { type: FieldLogicManager }, { type: FieldLogicDisplayManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class EmailDetailFieldsModule {
    static { this.ɵfac = function EmailDetailFieldsModule_Factory(t) { return new (t || EmailDetailFieldsModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: EmailDetailFieldsModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EmailDetailFieldsModule, [{
        type: NgModule,
        args: [{
                declarations: [EmailDetailFieldsComponent],
                exports: [EmailDetailFieldsComponent],
                imports: [
                    CommonModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EmailDetailFieldsModule, { declarations: [EmailDetailFieldsComponent], imports: [CommonModule], exports: [EmailDetailFieldsComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HtmlSanitizePipe {
    constructor(sanitizer) {
        this.sanitizer = sanitizer;
    }
    transform(data) {
        return this.sanitizer.sanitize(SecurityContext.HTML, data);
    }
    static { this.ɵfac = function HtmlSanitizePipe_Factory(t) { return new (t || HtmlSanitizePipe)(i0.ɵɵdirectiveInject(i1$5.DomSanitizer, 16)); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "htmlSanitize", type: HtmlSanitizePipe, pure: true }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlSanitizePipe, [{
        type: Pipe,
        args: [{
                name: 'htmlSanitize'
            }]
    }], function () { return [{ type: i1$5.DomSanitizer }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class HtmlSanitizeModule {
    static { this.ɵfac = function HtmlSanitizeModule_Factory(t) { return new (t || HtmlSanitizeModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: HtmlSanitizeModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlSanitizeModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    HtmlSanitizePipe
                ],
                exports: [
                    HtmlSanitizePipe
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(HtmlSanitizeModule, { declarations: [HtmlSanitizePipe], imports: [CommonModule], exports: [HtmlSanitizePipe] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ActionLogicHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AuthGuard {
    constructor(router, authService, asyncActionService, appState, routeConverter, language, notificationStore) {
        this.router = router;
        this.authService = authService;
        this.asyncActionService = asyncActionService;
        this.appState = appState;
        this.routeConverter = routeConverter;
        this.language = language;
        this.notificationStore = notificationStore;
    }
    canActivate(route, snapshot) {
        return this.authorizeUser(route, snapshot);
    }
    /**
     * Authorize user session and acl together in conjunction
     *
     * @returns {object} Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
     * @param {ActivatedRouteSnapshot} route information about the current route
     * @param snapshot
     */
    authorizeUser(route, snapshot) {
        // Note: this session and acl are not always booleans
        return forkJoin([
            this.authorizeUserSession(route, snapshot),
            this.authorizeUserACL(route)
        ]).pipe(map(([session, acl]) => {
            if (session instanceof UrlTree) {
                return session;
            }
            if (acl instanceof UrlTree) {
                return acl;
            }
            return session && acl;
        }));
    }
    /**
     * Authorize user acl
     *
     * @returns {object} Observable<boolean | UrlTree>
     * @param {ActivatedRouteSnapshot} activatedRoute information about the current route
     */
    authorizeUserACL(activatedRoute) {
        const routeInfo = this.routeConverter.parseRouteURL(activatedRoute.url);
        const routeURL = this.appState.getRouteUrl() ?? '';
        if (!routeInfo.module || routeInfo.module === 'home') {
            return of(true);
        }
        const homeUrl = '';
        const homeUrlTree = this.router.parseUrl(homeUrl);
        const actionName = 'user-acl';
        const asyncData = {
            action: actionName,
            module: routeInfo.module,
            payload: {
                routeAction: routeInfo.action,
                record: routeInfo.record,
                routeURL,
                queryParams: activatedRoute?.queryParams ?? []
            }
        };
        return this.asyncActionService.run(actionName, asyncData)
            .pipe(take(1), map((process) => {
            if (process.data && process.data.result === true) {
                return true;
            }
            if (isEmptyString(routeURL)) {
                // Re-direct to home
                return homeUrlTree;
            }
            const currentUrlTree = this.router.parseUrl(this.router.url);
            if (this.routeConverter.isClassicViewRoute(currentUrlTree)) {
                return currentUrlTree;
            }
            return false;
        }), catchError(() => of(homeUrlTree)));
    }
    /**
     * Authorize user session
     *
     * @returns {object} Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
     * @param {ActivatedRouteSnapshot} route information about the current route
     * @param snapshot
     */
    authorizeUserSession(route, snapshot) {
        if (this.authService.isUserLoggedIn.value && route.data.checkSession !== true) {
            return of(true);
        }
        let sessionExpiredUrl = this.authService.getSessionExpiredRoute();
        const redirect = this.authService.sessionExpiredRedirect();
        const sessionExpiredUrlTree = this.router.parseUrl(sessionExpiredUrl);
        return this.authService.fetchSessionStatus()
            .pipe(take(1), map((user) => {
            if (user && user.appStatus.installed === false) {
                return this.router.parseUrl('install');
            }
            if (user && user.active === true) {
                const wasLoggedIn = !!this.appState.getCurrentUser();
                this.authService.setCurrentUser(user);
                if (!wasLoggedIn) {
                    this.language.appStrings$.pipe(filter(appStrings => appStrings && !emptyObject(appStrings)), tap(() => {
                        this.notificationStore.enableNotifications();
                        this.notificationStore.refreshNotifications();
                    }), take(1)).subscribe();
                }
                if (user?.redirect?.route && (!snapshot.url.includes(user.redirect.route))) {
                    const redirectUrlTree = this.router.parseUrl(user.redirect.route);
                    redirectUrlTree.queryParams = user?.redirect?.queryParams ?? {};
                    return redirectUrlTree;
                }
                return true;
            }
            this.appState.setPreLoginUrl(snapshot.url);
            this.authService.resetState();
            if (redirect) {
                this.authService.handleSessionExpiredRedirect();
                return false;
            }
            // Re-direct to login
            return sessionExpiredUrlTree;
        }), catchError(() => {
            if (redirect) {
                this.authService.handleSessionExpiredRedirect();
                return of(false);
            }
            this.authService.logout('LBL_SESSION_EXPIRED', false);
            return of(sessionExpiredUrlTree);
        }), tap((result) => {
            if (result === true) {
                this.authService.isUserLoggedIn.next(true);
            }
        }));
    }
    static { this.ɵfac = function AuthGuard_Factory(t) { return new (t || AuthGuard)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(AuthService), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(RouteConverter), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NotificationStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthGuard, factory: AuthGuard.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthGuard, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$2.Router }, { type: AuthService }, { type: AsyncActionService }, { type: AppStateStore }, { type: RouteConverter }, { type: LanguageStore }, { type: NotificationStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ErrorInterceptor {
    intercept(request, next) {
        return next.handle(request).pipe(catchError(err => {
            return throwError(err);
        }));
    }
    static { this.ɵfac = function ErrorInterceptor_Factory(t) { return new (t || ErrorInterceptor)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ErrorInterceptor, factory: ErrorInterceptor.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ErrorInterceptor, [{
        type: Injectable
    }], null, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallAuthGuard {
    constructor(systemConfigStore, authService, router, routeConverter, asyncActionService, message) {
        this.systemConfigStore = systemConfigStore;
        this.authService = authService;
        this.router = router;
        this.routeConverter = routeConverter;
        this.asyncActionService = asyncActionService;
        this.message = message;
    }
    canActivate(route) {
        return this.canActivateWebInstallation(route);
    }
    /**
 * Allow web installation
 * @returns {object} Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree
 * @param activatedRoute
 */
    canActivateWebInstallation(activatedRoute) {
        const homePage = this.systemConfigStore.getHomePage();
        const homePageUrlTree = this.router.parseUrl(homePage);
        return this.authService.fetchSessionStatus()
            .pipe(take(1), map((user) => {
            if (user && user.appStatus.locked === true && user.appStatus.installed === true) {
                this.message.addDangerMessageByKey('LBL_DISABLED_TITLE_2');
                if (user && user.active === false) {
                    return homePageUrlTree;
                }
                return false;
            }
            if (user && user.active === true) {
                this.authService.logout('', false);
                this.authService.isUserLoggedIn.next(false);
            }
            return true;
        }), catchError(() => of(true)));
    }
    static { this.ɵfac = function InstallAuthGuard_Factory(t) { return new (t || InstallAuthGuard)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(AuthService), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(RouteConverter), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallAuthGuard, factory: InstallAuthGuard.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallAuthGuard, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SystemConfigStore }, { type: AuthService }, { type: i1$2.Router }, { type: RouteConverter }, { type: AsyncActionService }, { type: MessageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoginAuthGuard {
    constructor(router, authService, systemConfigStore, appStateStore) {
        this.router = router;
        this.authService = authService;
        this.systemConfigStore = systemConfigStore;
        this.appStateStore = appStateStore;
    }
    canActivate() {
        const homePage = this.systemConfigStore.getHomePage();
        const homePageUrlTree = this.router.parseUrl(homePage);
        if (this.authService.isUserLoggedIn.value) {
            return homePageUrlTree;
        }
        return this.authService.fetchSessionStatus()
            .pipe(take(1), map((user) => {
            if (user && user.appStatus.installed === false) {
                return this.router.parseUrl('install');
            }
            if (user && user.active === true) {
                // Session is active, go to home page
                this.authService.setCurrentUser(user);
                return homePageUrlTree;
            }
            // Stay on login
            return true;
        }), catchError(() => of(true)));
    }
    static { this.ɵfac = function LoginAuthGuard_Factory(t) { return new (t || LoginAuthGuard)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(AuthService), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(AppStateStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LoginAuthGuard, factory: LoginAuthGuard.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoginAuthGuard, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$2.Router }, { type: AuthService }, { type: SystemConfigStore }, { type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ExtensionLoader {
    constructor(systemConfigStore) {
        this.systemConfigStore = systemConfigStore;
    }
    /**
     * Load all extensions
     *
     * @param {object} injector Injector
     */
    load(injector) {
        const extensions = this.systemConfigStore.getConfigValue('extensions');
        const extensionModules$ = {};
        Object.keys(extensions).forEach(extensionName => {
            if (!extensions[extensionName]) {
                return;
            }
            const config = extensions[extensionName];
            if (!config.remoteEntry || !config.remoteName) {
                return;
            }
            if (!config.enabled || isFalse(config.enabled)) {
                return;
            }
            extensionModules$[extensionName] = this.loadExtension(config, injector);
        });
        if (Object.keys(extensionModules$).length < 1) {
            return of({});
        }
        //TODO: Correct here
        return forkJoin(extensionModules$);
    }
    /**
     * Load single extension
     *
     * @param {object} config ExtensionConfig
     * @param {object} injector Injector
     */
    loadExtension(config, injector) {
        const promise = () => loadRemoteModule({
            type: 'module',
            remoteEntry: config.remoteEntry,
            exposedModule: './Module'
        }).then(m => m.ExtensionModule);
        return this.loadModule(promise, injector);
    }
    /**
     * Check if object is a promise
     * @param {} obj promise
     * @returns {boolean} isPromise
     */
    isPromise(obj) {
        return !!obj && typeof obj.then === 'function';
    }
    /**
     * Wrap into observable
     *
     * @param {object} value to wrap
     * @returns {object} observable
     */
    wrapIntoObservable(value) {
        if (isObservable(value)) {
            // @ts-ignore
            return value;
        }
        if (this.isPromise(value)) {
            // @ts-ignore
            return from(Promise.resolve(value));
        }
        // @ts-ignore
        return of(value);
    }
    /**
     * Load module factory and return observable
     * @param {function} loadChildren
     */
    loadModule(loadChildren, injector) {
        return this.wrapIntoObservable(loadChildren()).pipe(map((module) => {
            return createNgModule(module, injector);
        }));
    }
    static { this.ɵfac = function ExtensionLoader_Factory(t) { return new (t || ExtensionLoader)(i0.ɵɵinject(SystemConfigStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ExtensionLoader, factory: ExtensionLoader.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ExtensionLoader, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseMetadataResolver {
    constructor(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, appState, moduleNameMapper, messageService, appMetadata, auth) {
        this.systemConfigStore = systemConfigStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.userPreferenceStore = userPreferenceStore;
        this.themeImagesStore = themeImagesStore;
        this.appState = appState;
        this.moduleNameMapper = moduleNameMapper;
        this.messageService = messageService;
        this.appMetadata = appMetadata;
        this.auth = auth;
    }
    resolve(route) {
        const module = this.calculateActiveModule(route);
        return this.appMetadata.load(module).pipe(tap(() => {
            if (this.auth.isLoggedIn()) {
                setTimeout(() => {
                    this.appMetadata.loadModuleMetadata(module).pipe(take(1)).subscribe();
                }, 0);
            }
        }));
    }
    /**
     * @param route
     */
    sequentialLoad(route) {
        const streams$ = {};
        if (this.isToLoadNavigation(route)) {
            streams$.navigation = this.navigationStore.load();
        }
        if (this.isToLoadConfigs(route)) {
            let configs$ = this.systemConfigStore.load();
            if (this.isToLoadLanguageStrings(route)) {
                const langStrings = this.getLanguagesToLoad(route);
                configs$ = configs$.pipe(map((configs) => {
                    let language = configs.default_language.value;
                    const storedLanguage = this.languageStore.getCurrentLanguage();
                    if (storedLanguage) {
                        language = storedLanguage;
                    }
                    return this.languageStore.load(language, langStrings);
                }), concatAll(), toArray());
            }
            streams$.configs = configs$;
        }
        if (this.isToLoadUserPreferences(route)) {
            streams$.preferences = this.userPreferenceStore.load();
        }
        const parallelStream$ = forkJoin(streams$);
        return parallelStream$.pipe(map((data) => {
            let theme = null;
            if (this.systemConfigStore.getConfigValue('default_theme')) {
                theme = this.systemConfigStore.getConfigValue('default_theme');
            }
            if (this.userPreferenceStore.getUserPreference('user_theme')) {
                theme = this.userPreferenceStore.getUserPreference('user_theme');
            }
            if (this.themeImagesStore.getTheme()) {
                theme = this.themeImagesStore.getTheme();
            }
            if (theme !== null) {
                return this.themeImagesStore.load(theme);
            }
            return data;
        }), concatAll(), toArray(), tap(() => this.appState.setLoaded(true)));
    }
    /**
     * Get Languages to Load
     *
     * @param {{}} route activated
     * @returns {string[]} languages
     */
    getLanguagesToLoad(route) {
        let langStrings = this.languageStore.getAvailableStringsTypes();
        if (this.isToLoadNavigation(route)) {
            return langStrings;
        }
        if (!route.data || !route.data.load) {
            return [];
        }
        if (Array.isArray(route.data.load.languageStrings)) {
            langStrings = route.data.load.languageStrings;
        }
        return langStrings;
    }
    /**
     * Should load language strings. True if navigation is to load
     *
     * @param {{}} route activated
     * @returns {boolean} is to load
     */
    isToLoadLanguageStrings(route) {
        if (this.isToLoadNavigation(route)) {
            return true;
        }
        if (!route.data || !route.data.load) {
            return false;
        }
        return Array.isArray(route.data.load.languageStrings) || route.data.load.languageStrings === true;
    }
    /**
     * Should load navigation. If not set defaults to true
     *
     * @param {{}} route activated
     * @returns {boolean} is to load
     */
    isToLoadConfigs(route) {
        if (!route.data || !route.data.load) {
            return true;
        }
        return route.data.load.configs !== false;
    }
    /**
     * Should load navigation, If not set defaults to true
     *
     * @param {{}} route activated
     * @returns {boolean} is to load
     */
    isToLoadNavigation(route) {
        if (!route.data || !route.data.load) {
            return true;
        }
        return route.data.load.navigation !== false;
    }
    /**
     * Should load user preferences. If not set defaults to true
     *
     * @param {{}} route activated
     * @returns {boolean} is to load
     */
    isToLoadUserPreferences(route) {
        if (!route.data || !route.data.load) {
            return true;
        }
        return route.data.load.preferences !== false;
    }
    addMetadataLoadErrorMessage() {
        let message = this.languageStore.getAppString('LBL_ERROR_FETCHING_METADATA');
        if (!message) {
            message = 'Error occurred while fetching metadata';
        }
        this.messageService.addDangerMessage(message);
    }
    /**
     * Calculate the active module
     *
     * @param {{}} route active
     * @returns {string} active module
     */
    calculateActiveModule(route) {
        let module = route.params.module;
        if (!module) {
            module = route.data.module;
        }
        const rootPath = route?.url[0]?.path ?? '';
        if (!module && rootPath !== '') {
            module = rootPath;
        }
        const parentModuleParam = this.getParentModuleMap()[module] || '';
        const parentModule = route.queryParams[parentModuleParam] || '';
        if (parentModule) {
            module = this.moduleNameMapper.toFrontend(parentModule);
        }
        return module;
    }
    /**
     * Get Parent Module Map
     *
     * @returns {{}} parent module map
     */
    getParentModuleMap() {
        return {
            'merge-records': 'return_module',
            import: 'import_module'
        };
    }
    static { this.ɵfac = function BaseMetadataResolver_Factory(t) { return new (t || BaseMetadataResolver)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(MessageService), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(AuthService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseMetadataResolver, factory: BaseMetadataResolver.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseMetadataResolver, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: LanguageStore }, { type: NavigationStore }, { type: UserPreferenceStore }, { type: ThemeImagesStore }, { type: AppStateStore }, { type: ModuleNameMapper }, { type: MessageService }, { type: AppMetadataStore }, { type: AuthService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseModuleResolver extends BaseMetadataResolver {
    constructor(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, moduleNameMapper, appStateStore, metadataStore, messageService, routeConverter, appMetadata, auth) {
        super(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, appStateStore, moduleNameMapper, messageService, appMetadata, auth);
        this.systemConfigStore = systemConfigStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.userPreferenceStore = userPreferenceStore;
        this.themeImagesStore = themeImagesStore;
        this.moduleNameMapper = moduleNameMapper;
        this.appStateStore = appStateStore;
        this.metadataStore = metadataStore;
        this.messageService = messageService;
        this.routeConverter = routeConverter;
        this.appMetadata = appMetadata;
        this.auth = auth;
    }
    resolve(route) {
        let routeModule = route.params.module;
        if (!routeModule) {
            routeModule = route.data.module;
        }
        return super.resolve(route).pipe(concatMap(() => forkJoin([
            this.metadataStore.load(routeModule, this.metadataStore.getMetadataTypes()),
            this.metadataStore.getMetadata('saved-search', ['recordView'])
        ])), map(value => {
            return {
                metadata: value[0] ?? {},
                savedSearchMeta: value[1] ?? {},
            };
        }), tap(() => {
            if (routeModule) {
                const module = this.calculateActiveModule(route);
                this.appStateStore.setModule(module);
            }
            const info = this.routeConverter.parseRouteURL(route.url);
            const action = info.action ?? 'index';
            this.appStateStore.setView(action);
        }, () => {
            this.addMetadataLoadErrorMessage();
        }));
    }
    static { this.ɵfac = function BaseModuleResolver_Factory(t) { return new (t || BaseModuleResolver)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RouteConverter), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(AuthService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseModuleResolver, factory: BaseModuleResolver.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseModuleResolver, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: LanguageStore }, { type: NavigationStore }, { type: UserPreferenceStore }, { type: ThemeImagesStore }, { type: ModuleNameMapper }, { type: AppStateStore }, { type: MetadataStore }, { type: MessageService }, { type: RouteConverter }, { type: AppMetadataStore }, { type: AuthService }]; }, null); })();

class RecentlyViewedService {
    constructor(metadata, globalRecentlyViewedStore, processService, moduleNameMapper, appMetadataStore, systemConfigs, appStateStore) {
        this.metadata = metadata;
        this.globalRecentlyViewedStore = globalRecentlyViewedStore;
        this.processService = processService;
        this.moduleNameMapper = moduleNameMapper;
        this.appMetadataStore = appMetadataStore;
        this.systemConfigs = systemConfigs;
        this.appStateStore = appStateStore;
    }
    /**
     * Public Api
     */
    /**
     * On navigation add
     * @param module
     * @param route
     */
    onNavigationAdd(module, route) {
        let mode = 'detail';
        const data = (route && route.data) || {};
        if (data.mode) {
            mode = data.mode;
        }
        const recordId = route?.params?.record ?? null;
        if (recordId && mode !== 'create') {
            const recentlyViewed = this.buildRecentlyViewed(module, recordId);
            this.addRecentlyViewed(module, recentlyViewed);
        }
    }
    /**
     * Build new recently viewed
     * @param module
     * @param id
     * @param view
     */
    buildRecentlyViewed(module, id, view = 'detailview') {
        module = this.moduleNameMapper.toLegacy(module);
        return deepClone({
            module: 'Tracker',
            type: 'Tracker',
            attributes: {
                module_name: module ?? '',
                item_id: id ?? '',
                action: view ?? '',
            },
        });
    }
    /**
     * Add recently viewed
     * @param module
     * @param viewed
     */
    addRecentlyViewed(module, viewed) {
        this.saveRecentlyViewed(module, viewed);
    }
    /**
     * Save recently viewed to backend
     * @param module
     * @param viewed
     */
    saveRecentlyViewed(module, viewed) {
        const processType = 'add-recently-viewed';
        const options = {
            recentlyViewed: viewed
        };
        setTimeout(() => {
            this.processService.submit(processType, options).pipe(take(1)).subscribe(result => {
                const saved = {
                    id: viewed.id ?? '',
                    module: viewed.module ?? '',
                    attributes: { ...(viewed.attributes ?? {}) },
                };
                const tracker = result?.data?.tracker ?? null;
                if (tracker === null) {
                    return;
                }
                saved.attributes.item_summary = tracker.item_summary;
                const newItemId = saved?.attributes?.item_id ?? '';
                const metadata = this.metadata.getModuleMeta(module);
                const current = metadata?.recentlyViewed ?? null;
                if (current) {
                    let cleared = current.filter(item => ((item?.attributes?.item_id ?? '') !== newItemId));
                    cleared.unshift(saved);
                    metadata.recentlyViewed = cleared;
                }
                this.globalRecentlyViewedStore.addToState(saved);
                this.metadata.setModuleMetadata(module, metadata);
            });
        }, 500);
    }
    conditionalGlobalRefresh(view = '') {
        const reloadActions = this.systemConfigs.getUi('global_recently_viewed_reload_actions') ?? null;
        const previousModule = this.getModule();
        if (!view) {
            view = this.getView();
        }
        if (!reloadActions || !previousModule) {
            return;
        }
        const actions = reloadActions[previousModule] ?? reloadActions['any'] ?? [];
        if (!actions || !actions.length) {
            return;
        }
        const reload = actions.some(action => {
            return action === 'any' || action === view;
        });
        if (reload) {
            this.appMetadataStore.load(this.getModule(), ['globalRecentlyViewed'], false).pipe(take(1)).subscribe();
        }
    }
    getModule() {
        return this.appStateStore.getModule();
    }
    getView() {
        return this.appStateStore.getView();
    }
    static { this.ɵfac = function RecentlyViewedService_Factory(t) { return new (t || RecentlyViewedService)(i0.ɵɵinject(MetadataStore), i0.ɵɵinject(GlobalRecentlyViewedStore), i0.ɵɵinject(ProcessService), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(AppStateStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecentlyViewedService, factory: RecentlyViewedService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecentlyViewedService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: MetadataStore }, { type: GlobalRecentlyViewedStore }, { type: ProcessService }, { type: ModuleNameMapper }, { type: AppMetadataStore }, { type: SystemConfigStore }, { type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BaseRecordResolver extends BaseModuleResolver {
    constructor(systemConfigStore, languageStore, navigationStore, metadataStore, userPreferenceStore, themeImagesStore, moduleNameMapper, actionNameMapper, appStateStore, messageService, routeConverter, router, appMetadata, auth, recentlyViewed) {
        super(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, moduleNameMapper, appStateStore, metadataStore, messageService, routeConverter, appMetadata, auth);
        this.systemConfigStore = systemConfigStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.metadataStore = metadataStore;
        this.userPreferenceStore = userPreferenceStore;
        this.themeImagesStore = themeImagesStore;
        this.moduleNameMapper = moduleNameMapper;
        this.actionNameMapper = actionNameMapper;
        this.appStateStore = appStateStore;
        this.messageService = messageService;
        this.routeConverter = routeConverter;
        this.router = router;
        this.appMetadata = appMetadata;
        this.auth = auth;
        this.recentlyViewed = recentlyViewed;
    }
    resolve(route) {
        let routeModule = route.params.module;
        if (!routeModule) {
            routeModule = route.data.module;
        }
        return super.resolve(route).pipe(concatMap(() => {
            return forkJoin([
                this.metadataStore.load(routeModule, this.metadataStore.getMetadataTypes()),
            ]);
        }), tap(() => {
            if (this.auth.isLoggedIn()) {
                this.recentlyViewed.onNavigationAdd(this.appStateStore.getModule(), route);
            }
        }));
    }
    static { this.ɵfac = function BaseRecordResolver_Factory(t) { return new (t || BaseRecordResolver)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(ActionNameMapper), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(RouteConverter), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(AuthService), i0.ɵɵinject(RecentlyViewedService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BaseRecordResolver, factory: BaseRecordResolver.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseRecordResolver, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: LanguageStore }, { type: NavigationStore }, { type: MetadataStore }, { type: UserPreferenceStore }, { type: ThemeImagesStore }, { type: ModuleNameMapper }, { type: ActionNameMapper }, { type: AppStateStore }, { type: MessageService }, { type: RouteConverter }, { type: i1$2.Router }, { type: AppMetadataStore }, { type: AuthService }, { type: RecentlyViewedService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecoverPasswordService {
    constructor(processService, appStateStore) {
        this.processService = processService;
        this.appStateStore = appStateStore;
        this.processType = 'recover-password';
    }
    /**
     * Send recover password request
     *
     * @param {string} userName to check
     * @param {string} email to check
     * @returns {{}} Observable<Process>
     */
    run(userName, email) {
        const options = {
            username: userName,
            useremail: email
        };
        this.appStateStore.updateLoading('recover-password', true, false);
        return this.processService
            .submit(this.processType, options)
            .pipe(tap(() => this.appStateStore.updateLoading('recover-password', false, false)), catchError(err => {
            this.appStateStore.updateLoading('recover-password', false, false);
            throw err;
        }));
    }
    static { this.ɵfac = function RecoverPasswordService_Factory(t) { return new (t || RecoverPasswordService)(i0.ɵɵinject(ProcessService), i0.ɵɵinject(AppStateStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecoverPasswordService, factory: RecoverPasswordService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecoverPasswordService, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: ProcessService }, { type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SystemNameService {
    constructor(systemConfig, doc) {
        this.systemConfig = systemConfig;
        this.docElement = doc;
    }
    setSystemName(systemName) {
        if (!systemName || systemName.length < 1) {
            systemName = 'SuiteCRM';
        }
        const head = this.docElement.documentElement.childNodes.item(0);
        head.childNodes.forEach((child) => {
            if (child.nodeName === 'TITLE') {
                child.textContent = systemName;
            }
        });
    }
    static { this.ɵfac = function SystemNameService_Factory(t) { return new (t || SystemNameService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(DOCUMENT)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SystemNameService, factory: SystemNameService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SystemNameService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: undefined, decorators: [{
                type: Inject,
                args: [DOCUMENT]
            }] }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class UserService {
    constructor(http) {
        this.http = http;
    }
    getAll() {
        return this.http.get('users');
    }
    static { this.ɵfac = function UserService_Factory(t) { return new (t || UserService)(i0.ɵɵinject(i1$3.HttpClient)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: UserService, factory: UserService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: i1$3.HttpClient }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SeriesStatisticsStoreFactory {
    constructor(fetchGQL) {
        this.fetchGQL = fetchGQL;
    }
    create() {
        return new SeriesStatisticsStore(this.fetchGQL);
    }
    static { this.ɵfac = function SeriesStatisticsStoreFactory_Factory(t) { return new (t || SeriesStatisticsStoreFactory)(i0.ɵɵinject(StatisticsFetchGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SeriesStatisticsStoreFactory, factory: SeriesStatisticsStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SeriesStatisticsStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: StatisticsFetchGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class StatisticsStoreFactory {
    constructor(fetchGQL) {
        this.fetchGQL = fetchGQL;
    }
    create() {
        return new StatisticsStore(this.fetchGQL);
    }
    static { this.ɵfac = function StatisticsStoreFactory_Factory(t) { return new (t || StatisticsStoreFactory)(i0.ɵɵinject(StatisticsFetchGQL)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: StatisticsStoreFactory, factory: StatisticsStoreFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StatisticsStoreFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: StatisticsFetchGQL }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function AdminCardComponent_div_1_ng_container_5_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9)(1, "a", 10)(2, "div", 11);
    i0.ɵɵelement(3, "scrm-image", 12)(4, "scrm-label", 13);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const item_r3 = ctx.$implicit;
    const isFirst_r4 = ctx.first;
    const ctx_r2 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("border-top", isFirst_r4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("queryParams", item_r3 == null ? null : item_r3.params)("routerLink", item_r3.link)("title", ctx_r2.language.getFieldLabel(item_r3.descriptionKey, "administration"));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("image", item_r3.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", item_r3.titleKey);
} }
function AdminCardComponent_div_1_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, AdminCardComponent_div_1_ng_container_5_div_1_Template, 5, 7, "div", 8);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r1.content.linkGroup);
} }
function AdminCardComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2)(1, "div", 3)(2, "h5", 4);
    i0.ɵɵelement(3, "scrm-label", 5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(4, "div", 6);
    i0.ɵɵtemplate(5, AdminCardComponent_div_1_ng_container_5_Template, 2, 1, "ng-container", 7);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("title", ctx_r0.language.getFieldLabel(ctx_r0.content.descriptionLabelKey, "administration"));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("labelKey", ctx_r0.content.titleLabelKey);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.content.linkGroup);
} }
class AdminCardComponent {
    constructor(language) {
        this.language = language;
    }
    static { this.ɵfac = function AdminCardComponent_Factory(t) { return new (t || AdminCardComponent)(i0.ɵɵdirectiveInject(LanguageStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AdminCardComponent, selectors: [["scrm-admin-card"]], inputs: { content: "content" }, decls: 2, vars: 1, consts: [[1, "widget-panel", "h-100", "shadow-sm"], ["class", "card h-100 panel-card border-0", 4, "ngIf"], [1, "card", "h-100", "panel-card", "border-0"], [1, "card-header"], [1, "card-title", "admin-card-title", "m-0", 3, "title"], ["module", "administration", 3, "labelKey"], [1, "card-body", "d-flex", "flex-column", "align-items-start"], [4, "ngIf"], ["class", "admin-card-link-box border-bottom w-100", 3, "border-top", 4, "ngFor", "ngForOf"], [1, "admin-card-link-box", "border-bottom", "w-100"], ["queryParamsHandling", "merge", 1, "card-link", "admin-card-link", 3, "queryParams", "routerLink", "title"], [1, "d-flex", "admin-card-link-wrapper", "align-items-center", "w-100", "p-1"], [1, "admin-card-icon", "sicon-2x", 3, "image"], ["module", "administration", 1, "admin-card-label", "pl-1", "flex-grow-1", 3, "labelKey"]], template: function AdminCardComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, AdminCardComponent_div_1_Template, 6, 3, "div", 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.content);
        } }, dependencies: [i2.NgForOf, i2.NgIf, i1$2.RouterLink, LabelComponent, ImageComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminCardComponent, [{
        type: Component,
        args: [{ selector: 'scrm-admin-card', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"widget-panel h-100 shadow-sm\">\n    <div *ngIf=\"content\" class=\"card h-100 panel-card border-0\">\n        <div class=\"card-header\">\n            <h5 [title]=\"language.getFieldLabel(content.descriptionLabelKey, 'administration')\"\n                class=\"card-title admin-card-title m-0\">\n                <scrm-label [labelKey]=\"content.titleLabelKey\" module=\"administration\"></scrm-label>\n            </h5>\n        </div>\n        <div class=\"card-body d-flex flex-column align-items-start\">\n            <ng-container *ngIf=\"content.linkGroup\">\n                <div *ngFor=\"let item of content.linkGroup; let isFirst = first\" [class.border-top]=\"isFirst\"\n                     class=\"admin-card-link-box border-bottom w-100\">\n                    <a [queryParams]=\"item?.params\"\n                       [routerLink]=\"item.link\"\n                       [title]=\"language.getFieldLabel(item.descriptionKey, 'administration')\"\n                       class=\"card-link admin-card-link\"\n                       queryParamsHandling=\"merge\">\n                        <div class=\"d-flex admin-card-link-wrapper align-items-center w-100 p-1 \">\n                            <scrm-image [image]=\"item.icon\" class=\"admin-card-icon sicon-2x\"></scrm-image>\n                            <scrm-label [labelKey]=\"item.titleKey\"\n                                        class=\"admin-card-label pl-1 flex-grow-1\"\n                                        module=\"administration\">\n                            </scrm-label>\n                        </div>\n\n                    </a>\n                </div>\n            </ng-container>\n        </div>\n    </div>\n</div>\n\n" }]
    }], function () { return [{ type: LanguageStore }]; }, { content: [{
            type: Input
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AdminCardModule {
    static { this.ɵfac = function AdminCardModule_Factory(t) { return new (t || AdminCardModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AdminCardModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            RouterModule,
            LabelModule,
            ImageModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminCardModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    AdminCardComponent
                ],
                exports: [
                    AdminCardComponent
                ],
                imports: [
                    CommonModule,
                    RouterModule,
                    LabelModule,
                    ImageModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AdminCardModule, { declarations: [AdminCardComponent], imports: [CommonModule,
        RouterModule,
        LabelModule,
        ImageModule], exports: [AdminCardComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function AdminPanelComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵelement(1, "scrm-admin-card", 4);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const data_r1 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("content", data_r1);
} }
class AdminPanelComponent {
    constructor(adminMetaData) {
        this.adminMetaData = adminMetaData;
        this.adminPanelData = [];
    }
    ngOnInit() {
        const adminData = this.adminMetaData.getAdminPanel();
        this.setData(adminData);
    }
    setData(adminData) {
        adminData.forEach(({ icon, titleLabelKey, descriptionLabelKey, linkGroup }) => {
            this.adminPanelData.push({
                icon,
                titleLabelKey,
                descriptionLabelKey,
                linkGroup: this.setLinkGroups(linkGroup)
            });
        });
    }
    setLinkGroups(groupData) {
        let linkGroups = [];
        let linkGroupKeys = Object.keys(groupData);
        for (let j = 0; j < linkGroupKeys.length; j++) {
            let linkGroup = groupData[linkGroupKeys[j]];
            let links = Object.values(linkGroup);
            for (let i = 0; i < links.length; i++) {
                linkGroups.push(links[i]);
            }
        }
        return linkGroups;
    }
    static { this.ɵfac = function AdminPanelComponent_Factory(t) { return new (t || AdminPanelComponent)(i0.ɵɵdirectiveInject(AdminMetadataStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AdminPanelComponent, selectors: [["scrm-admin-panel"]], decls: 3, vars: 1, consts: [[1, "admin-view", "full-height-view", "d-flex", "align-items-center"], [1, "row", "flex-grow-1"], ["class", "col-12 col-sm-6 col-lg-4 col-xl-3 mt-3 mb-3", 4, "ngFor", "ngForOf"], [1, "col-12", "col-sm-6", "col-lg-4", "col-xl-3", "mt-3", "mb-3"], [3, "content"]], template: function AdminPanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1);
            i0.ɵɵtemplate(2, AdminPanelComponent_div_2_Template, 2, 1, "div", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngForOf", ctx.adminPanelData);
        } }, dependencies: [i2.NgForOf, AdminCardComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminPanelComponent, [{
        type: Component,
        args: [{ selector: 'scrm-admin-panel', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2023 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"admin-view full-height-view d-flex align-items-center\">\n    <div class=\"row flex-grow-1\">\n        <div *ngFor=\"let data of adminPanelData\" class=\"col-12 col-sm-6 col-lg-4 col-xl-3 mt-3 mb-3\">\n\n            <scrm-admin-card [content]=\"data\"></scrm-admin-card>\n\n        </div>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: AdminMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AdminPanelModule {
    static { this.ɵfac = function AdminPanelModule_Factory(t) { return new (t || AdminPanelModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AdminPanelModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AdminCardModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AdminPanelModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    AdminPanelComponent
                ],
                exports: [
                    AdminPanelComponent
                ],
                imports: [
                    CommonModule,
                    AdminCardModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AdminPanelModule, { declarations: [AdminPanelComponent], imports: [CommonModule,
        AdminCardModule], exports: [AdminPanelComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$3 = ["dataContainer"];
class ClassicViewUiComponent {
    constructor(route, router, sanitizer, routeConverter, auth, ngZone, systemConfigs) {
        this.route = route;
        this.router = router;
        this.sanitizer = sanitizer;
        this.routeConverter = routeConverter;
        this.auth = auth;
        this.ngZone = ngZone;
        this.systemConfigs = systemConfigs;
        this.iframe = null;
    }
    ngOnInit() {
        this.url = this.route.snapshot.data.legacyUrl;
    }
    ngAfterViewInit() {
        this.initIframe();
    }
    ngOnDestroy() {
        this.cleanObservers();
        this.iframe = null;
        const placeholder = this.wrapper;
        if (this.wrapper.firstChild) {
            placeholder.removeChild(placeholder.firstChild);
        }
        placeholder.innerHTML = '<iframe></iframe>';
        this.wrapper = null;
    }
    cleanObservers() {
        if (this.iframeResizeHandler) {
            this.iframeResizeHandler.destroy();
            this.iframeResizeHandler = null;
        }
        if (this.iframePageChangeHandler) {
            this.iframePageChangeHandler.destroy();
            this.iframePageChangeHandler = null;
        }
    }
    initIframe() {
        this.wrapper = this.dataContainer.nativeElement;
        if (this.wrapper.firstChild) {
            this.wrapper.removeChild(this.wrapper.firstChild);
        }
        const iframe = document.createElement('iframe');
        iframe.src = this.url;
        this.wrapper.appendChild(iframe);
        this.iframe = iframe;
        this.iframe.style.display = 'block';
        this.initObservers();
    }
    initObservers() {
        this.iframePageChangeHandler = this.buildIframePageChangeObserver();
        this.iframeResizeHandler = this.buildIframeResizeHandlerHandler();
        if (this.iframePageChangeHandler) {
            this.iframePageChangeHandler.init();
        }
    }
    onPageChange(newLocation) {
        if (this.shouldRedirect(newLocation) === false) {
            this.iframe.style.display = 'block';
            this.cleanObservers();
            this.initObservers();
            return;
        }
        const location = this.routeConverter.toFrontEndRoute(newLocation);
        if (location === '/users/login') {
            this.auth.logout('LBL_SESSION_EXPIRED');
            return;
        }
        this.ngZone.run(() => this.router.navigateByUrl(location).then()).then();
    }
    onIFrameLoad() {
        // Do not show scroll at any time, to avoid flickering
        this.iframe.contentWindow.document.body.style.overflow = 'hidden';
        // Init resize handler
        this.iframeResizeHandler.init(this.iframe);
        this.forceCacheRebuildAfterRepairAndRebuild();
    }
    // Temporary solution. Force a cache rebuild after quick repair and rebuild.
    // Can be removed after Repair and Rebuild page is re-done with to Suite8 views.
    forceCacheRebuildAfterRepairAndRebuild() {
        const iframeUrl = this.iframe.contentWindow.location.href;
        const url = new URL(iframeUrl);
        const params = new URLSearchParams(url.search);
        if (params.get('module') === 'Administration' && params.get('action') === 'repair') {
            this.auth.fetchSessionStatus().pipe(take(1)).subscribe();
        }
    }
    onIFrameUnload() {
        // hide iframe, while being re-directed
        this.iframe.style.display = 'none';
        this.iframeResizeHandler.destroy();
    }
    buildIframePageChangeObserver() {
        return new IframePageChangeObserver(this.iframe, this.onPageChange.bind(this), this.onIFrameLoad.bind(this), this.onIFrameUnload.bind(this));
    }
    buildIframeResizeHandlerHandler() {
        return new IframeResizeHandlerHandler();
    }
    /**
     * Check if should re-direct to link or if it was excluded
     *
     * @param {string} legacyLink to check
     * @returns {boolean} should redirect
     */
    shouldRedirect(legacyLink) {
        if (legacyLink && legacyLink.includes('/#/')) {
            return true;
        }
        const routeInfo = this.routeConverter.parse(legacyLink);
        // if no route or no module, don't re-direct
        if (!routeInfo || !routeInfo.module) {
            return false;
        }
        const reuse = this.routeConverter.matchesActiveRoute(this.route, routeInfo);
        if (reuse === true) {
            return false;
        }
        if (!routeInfo.action) {
            return true;
        }
        return this.toExclude(routeInfo);
    }
    /**
     * Check if given route is to exclude from redirection
     *
     * @param {object} routeInfo to check
     * @returns {boolean} is to exclude
     */
    toExclude(routeInfo) {
        const exclusions = this.systemConfigs.getConfigValue('classicview_routing_exclusions');
        if (!exclusions || Object.keys(exclusions).length === 0) {
            return true;
        }
        // if action is excluded for any module, don't re-direct
        if (exclusions.any && exclusions.any.includes(routeInfo.action)) {
            return false;
        }
        if (!exclusions[routeInfo.module]) {
            return true;
        }
        // if module action is excluded, don't re-direct
        const moduleExclusions = exclusions[routeInfo.module];
        return !(moduleExclusions && moduleExclusions.includes(routeInfo.action));
    }
    static { this.ɵfac = function ClassicViewUiComponent_Factory(t) { return new (t || ClassicViewUiComponent)(i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i1$5.DomSanitizer), i0.ɵɵdirectiveInject(RouteConverter), i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ClassicViewUiComponent, selectors: [["scrm-classic-view-ui"]], viewQuery: function ClassicViewUiComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0$3, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dataContainer = _t.first);
        } }, decls: 3, vars: 0, consts: [[1, "classic-view-container"], ["dataContainer", ""]], template: function ClassicViewUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0, 1);
            i0.ɵɵelement(2, "iframe");
            i0.ɵɵelementEnd();
        } }, encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassicViewUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-classic-view-ui', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"classic-view-container\" #dataContainer>\n    <iframe></iframe>\n</div>\n" }]
    }], function () { return [{ type: i1$2.ActivatedRoute }, { type: i1$2.Router }, { type: i1$5.DomSanitizer }, { type: RouteConverter }, { type: AuthService }, { type: i0.NgZone }, { type: SystemConfigStore }]; }, { dataContainer: [{
            type: ViewChild,
            args: ['dataContainer', { static: true }]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ClassicViewUiModule {
    static { this.ɵfac = function ClassicViewUiModule_Factory(t) { return new (t || ClassicViewUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ClassicViewUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassicViewUiModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    ClassicViewUiComponent,
                ],
                exports: [
                    ClassicViewUiComponent
                ],
                imports: [
                    CommonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ClassicViewUiModule, { declarations: [ClassicViewUiComponent], imports: [CommonModule], exports: [ClassicViewUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ClassicViewResolver extends BaseMetadataResolver {
    constructor(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, moduleNameMapper, routeConverter, messageService, appStateStore, appMetadata, auth, recentlyViewed, metadataStore) {
        super(systemConfigStore, languageStore, navigationStore, userPreferenceStore, themeImagesStore, appStateStore, moduleNameMapper, messageService, appMetadata, auth);
        this.systemConfigStore = systemConfigStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.userPreferenceStore = userPreferenceStore;
        this.themeImagesStore = themeImagesStore;
        this.moduleNameMapper = moduleNameMapper;
        this.routeConverter = routeConverter;
        this.messageService = messageService;
        this.appStateStore = appStateStore;
        this.appMetadata = appMetadata;
        this.auth = auth;
        this.recentlyViewed = recentlyViewed;
        this.metadataStore = metadataStore;
    }
    resolve(route) {
        const module = this.calculateActiveModule(route);
        return super.resolve(route).pipe(concatMap(() => {
            return forkJoin([
                this.metadataStore.load(module, this.metadataStore.getMetadataTypes()),
            ]);
        }), map(() => this.routeConverter.toLegacy(route.params, route.queryParams)), tap(() => {
            if (route.params.module) {
                const module = this.calculateActiveModule(route);
                this.appStateStore.setModule(module);
            }
            const info = this.routeConverter.parseRouteURL(route.url);
            const action = info.action ?? 'index';
            this.appStateStore.setView(action);
            this.recentlyViewed.onNavigationAdd(this.appStateStore.getModule(), route);
        }, () => {
            this.addMetadataLoadErrorMessage();
        }));
    }
    static { this.ɵfac = function ClassicViewResolver_Factory(t) { return new (t || ClassicViewResolver)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(ThemeImagesStore), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(RouteConverter), i0.ɵɵinject(MessageService), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(AppMetadataStore), i0.ɵɵinject(AuthService), i0.ɵɵinject(RecentlyViewedService), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ClassicViewResolver, factory: ClassicViewResolver.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassicViewResolver, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], function () { return [{ type: SystemConfigStore }, { type: LanguageStore }, { type: NavigationStore }, { type: UserPreferenceStore }, { type: ThemeImagesStore }, { type: ModuleNameMapper }, { type: RouteConverter }, { type: MessageService }, { type: AppStateStore }, { type: AppMetadataStore }, { type: AuthService }, { type: RecentlyViewedService }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CreateViewStore extends RecordViewStore {
    constructor(recordFetchGQL, recordSaveGQL, appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore, localStorage, message, subpanelFactory, recordManager, statisticsBatch, auth, recordStoreFactory, preferences, panelLogicManager, recordConvertService) {
        super(recordFetchGQL, recordSaveGQL, appStateStore, languageStore, navigationStore, moduleNavigation, metadataStore, localStorage, message, subpanelFactory, recordManager, statisticsBatch, recordStoreFactory, preferences, panelLogicManager, recordConvertService);
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.appStateStore = appStateStore;
        this.languageStore = languageStore;
        this.navigationStore = navigationStore;
        this.moduleNavigation = moduleNavigation;
        this.metadataStore = metadataStore;
        this.localStorage = localStorage;
        this.message = message;
        this.subpanelFactory = subpanelFactory;
        this.recordManager = recordManager;
        this.statisticsBatch = statisticsBatch;
        this.auth = auth;
        this.recordStoreFactory = recordStoreFactory;
        this.preferences = preferences;
        this.panelLogicManager = panelLogicManager;
        this.recordConvertService = recordConvertService;
    }
    /**
     * Initial record load if not cached and update state.
     * Returns observable to be used in resolver if needed
     *
     * @param {string} module to use
     * @param {string} recordID to use
     * @param {string} mode to use
     * @param {object} params to set
     * @returns {object} Observable<any>
     */
    init(module, recordID, mode = 'detail', params = {}) {
        this.internalState.module = module;
        this.internalState.recordID = recordID;
        this.setMode(mode);
        this.parseParams(params);
        this.calculateShowWidgets();
        this.showTopWidget = false;
        this.showSubpanels = false;
        const isDuplicate = this.params.isDuplicate ?? false;
        const isConvert = this.params.isConvert ?? false;
        const isOriginalId = this.params.originalId ?? false;
        const convertModule = this.params.convertModule ?? '';
        if (!isDuplicate && !isConvert && !isOriginalId) {
            this.initRecord(params);
        }
        if (isConvert && isOriginalId && convertModule) {
            return this.duplicateOnModule();
        }
        return this.load();
    }
    save() {
        this.appStateStore.updateLoading(`${this.internalState.module}-record-save-new`, true);
        return this.recordStore.save().pipe(catchError(() => {
            this.message.addDangerMessageByKey('LBL_ERROR_SAVING');
            return of({});
        }), finalize(() => {
            this.setMode('detail');
            this.appStateStore.updateLoading(`${this.internalState.module}-record-save-new`, false);
        }));
    }
    /**
     * Init record using params
     *
     * @param {object} params queryParams
     */
    initRecord(params = {}) {
        const user = this.auth.getCurrentUser();
        const blankRecord = {
            id: '',
            type: '',
            module: this.internalState.module,
            /* eslint-disable camelcase,@typescript-eslint/camelcase */
            attributes: {
                assigned_user_id: user.id,
                assigned_user_name: {
                    id: user.id,
                    user_name: user.userName
                },
                relate_to: params?.return_relationship,
                relate_id: params?.parent_id
            }
            /* eslint-enable camelcase,@typescript-eslint/camelcase */
        };
        this.recordManager.injectParamFields(params, blankRecord, this.getVardefs());
        this.recordStore.init(blankRecord, true);
    }
    /**
     * Load / reload record using current pagination and criteria
     *
     * @returns {object} Observable<RecordViewState>
     */
    load() {
        if ((this.params.isDuplicate ?? false) && (this.params.originalId ?? false)) {
            this.updateState({
                ...this.internalState,
                loading: true
            });
            return this.recordStore.retrieveRecord(this.internalState.module, this.params.originalId, false).pipe(tap((data) => {
                data.id = '';
                data.attributes.id = '';
                // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
                data.attributes.date_entered = '';
                this.recordManager.injectParamFields(this.params, data, this.getVardefs());
                this.recordStore.setRecord(data);
                this.updateState({
                    ...this.internalState,
                    module: data.module,
                    loading: false
                });
            }));
        }
        return of(this.recordStore.getBaseRecord()).pipe(shareReplay());
    }
    duplicateOnModule() {
        this.initRecord();
        const newRecord = this.getBaseRecord();
        const moduleMetadata = this.metadataStore.getModuleMeta(this.params.convertModule);
        const viewDefinitions$ = this.recordConvertService.getViewFieldsObservable(moduleMetadata);
        const prevModuleRecordStore = this.recordStoreFactory.create(viewDefinitions$);
        const prevRecord = prevModuleRecordStore.retrieveRecord(this.params.convertModule, this.params.originalId, false).pipe(map((record) => {
            return this.recordConvertService.duplicateOnModule(record, newRecord, this.getVardefs(), moduleMetadata);
        }), tap((record) => {
            this.recordStore.setRecord(record);
            this.updateState({
                ...this.internalState,
                module: this.internalState.module,
                loading: false
            });
        }));
        return prevRecord;
    }
    /**
     * Calculate if widgets are to display
     */
    calculateShowWidgets() {
        const show = false;
        this.showSidebarWidgets = show;
        this.widgets = show;
    }
    static { this.ɵfac = function CreateViewStore_Factory(t) { return new (t || CreateViewStore)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(NavigationStore), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(MessageService), i0.ɵɵinject(SubpanelStoreFactory), i0.ɵɵinject(RecordManager), i0.ɵɵinject(StatisticsBatch), i0.ɵɵinject(AuthService), i0.ɵɵinject(RecordStoreFactory), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(PanelLogicManager), i0.ɵɵinject(RecordConvertService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CreateViewStore, factory: CreateViewStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CreateViewStore, [{
        type: Injectable
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: AppStateStore }, { type: LanguageStore }, { type: NavigationStore }, { type: ModuleNavigation }, { type: MetadataStore }, { type: LocalStorageService }, { type: MessageService }, { type: SubpanelStoreFactory }, { type: RecordManager }, { type: StatisticsBatch }, { type: AuthService }, { type: RecordStoreFactory }, { type: UserPreferenceStore }, { type: PanelLogicManager }, { type: RecordConvertService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordActionHandler extends ActionHandler {
    checkRecordAccess(data, defaultAcls = []) {
        const record = data.store.recordStore.getBaseRecord();
        const acls = record.acls ?? [];
        if (!acls || !acls.length) {
            return false;
        }
        const action = data.action ?? null;
        return this.checkAccess(action, acls, defaultAcls);
    }
    /**
     * Navigate back
     * @param navigation
     * @param params
     * @param id
     * @param moduleName
     * @param record
     */
    navigateBack(navigation, params, id, moduleName, record) {
        let returnModule = navigation.getReturnModule(params);
        let returnAction = navigation.getReturnAction(params);
        let returnId = navigation.getReturnId(params);
        if (id === returnId) {
            return;
        }
        if (returnModule === moduleName &&
            returnAction === 'record' &&
            returnId !== id) {
            return;
        }
        if (!returnModule || !returnAction) {
            return;
        }
        navigation.navigateBack(record, moduleName, params);
    }
    navigateBackToDetail(navigation, router, recordPaginationService, id, moduleName) {
        const nextRoute = navigation.getRecordRouterLink(moduleName, id);
        router.navigate([nextRoute], { queryParams: { offset: recordPaginationService.getOffsetFromUrl() } });
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPaginationService {
    constructor(localStorageService, preferences, appStateStore, route) {
        this.localStorageService = localStorageService;
        this.preferences = preferences;
        this.appStateStore = appStateStore;
        this.route = route;
        this.nextRecordSubject = new BehaviorSubject(false);
        this.nextRecord$ = this.nextRecordSubject.asObservable();
        this.paginationType = PaginationType.PAGINATION;
        this.subs = [];
    }
    triggerNextRecord(value) {
        this.nextRecordSubject.next(value);
    }
    updateRecordListLocalStorage(records, pagination) {
        const module = this.getModule();
        const recordPaginationObj = {
            pagination: pagination,
            recordIds: this.mapRecordIds(records)
        };
        this.updatePaginationLocalStorage(pagination);
        this.savePreference(module, 'current-record-pagination', recordPaginationObj);
    }
    updatePaginationLocalStorage(pagination) {
        const module = this.getModule();
        const key = module + '-' + 'listview-current-pagination';
        this.localStorageService.set(key, pagination);
    }
    savePreference(module, storageKey, value) {
        this.preferences.setUi(module, this.getPreferenceKey(storageKey), value);
    }
    getPreferenceKey(storageKey) {
        return 'recordview-' + storageKey;
    }
    mapRecordIds(records) {
        return records.map(record => ({ id: record.id }));
    }
    getModule() {
        return this.appStateStore.getModule();
    }
    getTotalRecords() {
        const key = this.getModule() + '-' + 'listview-current-pagination';
        const currentPagination = this.localStorageService.get(key);
        return currentPagination?.total;
    }
    checkRecordValid(recordId) {
        const paginationObj = this.getRecordPaginationObj(this.getModule());
        const pagination = paginationObj?.pagination;
        const recordIds = paginationObj?.recordIds;
        if (!pagination) {
            return false;
        }
        const pageSize = this.getPageSize();
        const offset = this.getOffsetFromUrl();
        if (this.paginationType === PaginationType.LOAD_MORE && (offset > pageSize)) {
            return false;
        }
        let index = (offset - 1) % pageSize;
        if (this.paginationType === PaginationType.LOAD_MORE) {
            index = offset - 1;
        }
        if (index >= 0 && index < recordIds.length) {
            return recordIds[index]?.id === recordId;
        }
        return false;
    }
    getPageSize() {
        const paginationObj = this.getRecordPaginationObj(this.getModule());
        return paginationObj?.pagination?.pageSize;
    }
    getOffsetFromUrl() {
        const queryParams = this.route.snapshot.queryParamMap;
        return toNumber(queryParams.get('offset'));
    }
    getRecordPaginationObj(module) {
        const key = module + '-' + 'recordview-current-record-pagination';
        const data = this.localStorageService.get(key)[module];
        if (!data || emptyObject(data)) {
            return;
        }
        return data;
    }
    static { this.ɵfac = function RecordPaginationService_Factory(t) { return new (t || RecordPaginationService)(i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(AppStateStore), i0.ɵɵinject(i1$2.ActivatedRoute)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPaginationService, factory: RecordPaginationService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPaginationService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: LocalStorageService }, { type: UserPreferenceStore }, { type: AppStateStore }, { type: i1$2.ActivatedRoute }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordCancelAction extends RecordActionHandler {
    constructor(modalService, navigation, router, recordPaginationService) {
        super();
        this.modalService = modalService;
        this.navigation = navigation;
        this.router = router;
        this.recordPaginationService = recordPaginationService;
        this.key = 'cancel';
        this.modes = ['edit', 'detail'];
    }
    run(data) {
        if (data.store.recordStore.isDirty()) {
            this.showConfirmationModal(data);
            return;
        }
        this.cancel(data);
    }
    shouldDisplay() {
        return true;
    }
    cancel(data) {
        const params = data.store.params;
        const moduleName = data.store.getModuleName();
        const id = data.store.getRecordId();
        const record = data.store.getBaseRecord();
        const currentUrl = this.router.url;
        if (currentUrl.includes('edit')) {
            this.navigateBackToDetail(this.navigation, this.router, this.recordPaginationService, id, moduleName);
        }
        else {
            this.navigateBack(this.navigation, params, id, moduleName, record);
        }
        data.store.recordStore.resetStaging();
        data.store.setMode('detail');
    }
    showConfirmationModal(data) {
        const modal = this.modalService.open(MessageModalComponent);
        modal.componentInstance.textKey = 'WARN_UNSAVED_CHANGES';
        modal.componentInstance.buttons = [
            {
                labelKey: 'LBL_CANCEL',
                klass: ['btn-secondary'],
                onClick: activeModal => activeModal.dismiss()
            },
            {
                labelKey: 'LBL_PROCEED',
                klass: ['btn-main'],
                onClick: activeModal => {
                    this.cancel(data);
                    activeModal.close();
                }
            },
        ];
    }
    static { this.ɵfac = function RecordCancelAction_Factory(t) { return new (t || RecordCancelAction)(i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(RecordPaginationService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordCancelAction, factory: RecordCancelAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordCancelAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i3$1.NgbModal }, { type: ModuleNavigation }, { type: i1$2.Router }, { type: RecordPaginationService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordSaveAction extends RecordActionHandler {
    constructor(router, message, navigation, notificationStore, recentlyViewedService, recordPaginationService) {
        super();
        this.router = router;
        this.message = message;
        this.navigation = navigation;
        this.notificationStore = notificationStore;
        this.recentlyViewedService = recentlyViewedService;
        this.recordPaginationService = recordPaginationService;
        this.key = 'save';
        this.modes = ['edit'];
    }
    run(data) {
        const isFieldLoading = Object.keys(data.store.recordStore.getStaging().fields).some(fieldKey => {
            const field = data.store.recordStore.getStaging().fields[fieldKey];
            return field.loading ?? false;
        });
        if (isFieldLoading) {
            this.message.addWarningMessageByKey('LBL_LOADING_IN_PROGRESS');
            return;
        }
        data.store.recordStore.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                data.store.save().pipe(take(1)).subscribe(record => {
                    const params = data.store.params;
                    const moduleName = data.store.getModuleName();
                    const id = record.id;
                    this.notificationStore.conditionalNotificationRefresh('edit');
                    const recentlyViewed = this.recentlyViewedService.buildRecentlyViewed(moduleName, id);
                    this.recentlyViewedService.addRecentlyViewed(moduleName, recentlyViewed);
                    const currentUrl = this.router.url;
                    if (currentUrl.includes('edit')) {
                        this.navigateBackToDetail(this.navigation, this.router, this.recordPaginationService, id, moduleName);
                    }
                    else {
                        this.navigateBack(this.navigation, params, id, moduleName, record);
                    }
                });
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function RecordSaveAction_Factory(t) { return new (t || RecordSaveAction)(i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(MessageService), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(NotificationStore), i0.ɵɵinject(RecentlyViewedService), i0.ɵɵinject(RecordPaginationService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordSaveAction, factory: RecordSaveAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordSaveAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i1$2.Router }, { type: MessageService }, { type: ModuleNavigation }, { type: NotificationStore }, { type: RecentlyViewedService }, { type: RecordPaginationService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordToggleWidgetsAction extends RecordActionHandler {
    constructor() {
        super();
        this.key = 'toggle-widgets';
        this.modes = ['detail', 'edit'];
    }
    run(data) {
        data.store.showSidebarWidgets = !data.store.showSidebarWidgets;
    }
    shouldDisplay(data) {
        return data.store.widgets;
    }
    getStatus(data) {
        return data.store.showSidebarWidgets ? 'active' : '';
    }
    static { this.ɵfac = function RecordToggleWidgetsAction_Factory(t) { return new (t || RecordToggleWidgetsAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordToggleWidgetsAction, factory: RecordToggleWidgetsAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordToggleWidgetsAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordEditAction extends RecordActionHandler {
    constructor() {
        super();
        this.key = 'edit';
        this.modes = ['detail'];
    }
    run(data) {
        data.store.setMode('edit');
    }
    shouldDisplay(data) {
        return this.checkRecordAccess(data, ['edit']);
    }
    static { this.ɵfac = function RecordEditAction_Factory(t) { return new (t || RecordEditAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordEditAction, factory: RecordEditAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordEditAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordCreateAction extends RecordActionHandler {
    constructor(moduleNameMapper, router) {
        super();
        this.moduleNameMapper = moduleNameMapper;
        this.router = router;
        this.key = 'create';
        this.modes = ['detail'];
    }
    run(data) {
        const store = data.store;
        const baseRecord = store.getBaseRecord();
        const route = '/' + store.vm.appData.module.name + '/edit';
        const module = this.moduleNameMapper.toLegacy(store.vm.appData.module.name);
        this.router.navigate([route], {
            queryParams: {
                // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
                return_module: module,
                // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
                return_action: 'DetailView',
                // eslint-disable-next-line camelcase,@typescript-eslint/camelcase
                return_record: (baseRecord && baseRecord.id) || ''
            }
        }).then();
    }
    shouldDisplay(data) {
        return this.checkRecordAccess(data, ['edit']);
    }
    static { this.ɵfac = function RecordCreateAction_Factory(t) { return new (t || RecordCreateAction)(i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(i1$2.Router)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordCreateAction, factory: RecordCreateAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordCreateAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ModuleNameMapper }, { type: i1$2.Router }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordSaveNewAction extends RecordActionHandler {
    constructor(message, navigation) {
        super();
        this.message = message;
        this.navigation = navigation;
        this.key = 'saveNew';
        this.modes = ['create'];
    }
    run(data) {
        data.store.recordStore.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                data.store.save().pipe(take(1)).subscribe(record => {
                    const store = data.store;
                    const params = store.params;
                    const moduleName = store.getModuleName();
                    this.navigation.navigateBack(record, moduleName, params);
                });
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function RecordSaveNewAction_Factory(t) { return new (t || RecordSaveNewAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(ModuleNavigation)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordSaveNewAction, factory: RecordSaveNewAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordSaveNewAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: ModuleNavigation }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CancelCreateAction extends RecordActionHandler {
    constructor(modalService, router, moduleNameMapper, actionNameMapper) {
        super();
        this.modalService = modalService;
        this.router = router;
        this.moduleNameMapper = moduleNameMapper;
        this.actionNameMapper = actionNameMapper;
        this.key = 'cancelCreate';
        this.modes = ['create'];
    }
    run(data) {
        if (data.store.recordStore.isDirty()) {
            this.showConfirmationModal(data);
            return;
        }
        this.cancel(data);
    }
    shouldDisplay() {
        return true;
    }
    cancel(data) {
        const store = data.store;
        let returnAction = store.params.return_action || '';
        let returnId = store.params.return_id || '';
        let returnModule = store.getModuleName();
        if (store.params.return_module) {
            returnModule = this.moduleNameMapper.toFrontend(store.params.return_module);
        }
        if (store.params.isConvert) {
            returnModule = this.moduleNameMapper.toFrontend(store.params.convertModule);
            returnId = store.params.originalId;
        }
        let route = '/' + returnModule;
        if (returnAction) {
            returnAction = this.actionNameMapper.toFrontend(returnAction);
            if (returnAction !== 'record' || returnId) {
                route += '/' + returnAction;
            }
        }
        if (returnId) {
            route += '/' + returnId;
        }
        this.router.navigate([route]).then();
    }
    showConfirmationModal(data) {
        const modal = this.modalService.open(MessageModalComponent);
        modal.componentInstance.textKey = 'WARN_UNSAVED_CHANGES';
        modal.componentInstance.buttons = [
            {
                labelKey: 'LBL_CANCEL',
                klass: ['btn-secondary'],
                onClick: activeModal => activeModal.dismiss()
            },
            {
                labelKey: 'LBL_OK',
                klass: ['btn-main'],
                onClick: activeModal => {
                    this.cancel(data);
                    activeModal.close();
                }
            },
        ];
    }
    static { this.ɵfac = function CancelCreateAction_Factory(t) { return new (t || CancelCreateAction)(i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(ModuleNameMapper), i0.ɵɵinject(ActionNameMapper)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CancelCreateAction, factory: CancelCreateAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CancelCreateAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: i3$1.NgbModal }, { type: i1$2.Router }, { type: ModuleNameMapper }, { type: ActionNameMapper }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessRecordAction extends RecordActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        const defaultAcls = data?.action?.acl ?? [];
        if (!defaultAcls.length) {
            return true;
        }
        return this.checkRecordAccess(data, defaultAcls);
    }
    static { this.ɵfac = function AsyncProcessRecordAction_Factory(t) { return new (t || AsyncProcessRecordAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessRecordAction, factory: AsyncProcessRecordAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessRecordAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordSaveContinueAction extends RecordActionHandler {
    constructor(message, navigation, notificationStore, systemConfigStore, recentlyViewedService, recordPaginationService) {
        super();
        this.message = message;
        this.navigation = navigation;
        this.notificationStore = notificationStore;
        this.systemConfigStore = systemConfigStore;
        this.recentlyViewedService = recentlyViewedService;
        this.recordPaginationService = recordPaginationService;
        this.key = 'saveContinue';
        this.modes = ['edit'];
    }
    run(data) {
        const isFieldLoading = Object.keys(data.store.recordStore.getStaging().fields).some(fieldKey => {
            const field = data.store.recordStore.getStaging().fields[fieldKey];
            return field.loading ?? false;
        });
        if (isFieldLoading) {
            this.message.addWarningMessageByKey('LBL_LOADING_IN_PROGRESS');
            return;
        }
        data.store.recordStore.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                data.store.saveOnEdit().pipe(take(1)).subscribe(record => {
                    const moduleName = data.store.getModuleName();
                    const id = record.id;
                    this.notificationStore.conditionalNotificationRefresh('edit');
                    const recentlyViewed = this.recentlyViewedService.buildRecentlyViewed(moduleName, id);
                    this.recentlyViewedService.addRecentlyViewed(moduleName, recentlyViewed);
                });
                this.recordPaginationService.triggerNextRecord(true);
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay(data) {
        const isEnabled = this.systemConfigStore.getConfigValue('enable_record_pagination');
        if (!isEnabled) {
            return false;
        }
        const totalRecords = this.recordPaginationService.getTotalRecords();
        const offset = this.recordPaginationService.getOffsetFromUrl();
        if (!totalRecords || !offset ||
            (offset >= totalRecords) ||
            (offset <= 0)) {
            return false;
        }
        return this.recordPaginationService.checkRecordValid(data.store.getRecordId());
    }
    static { this.ɵfac = function RecordSaveContinueAction_Factory(t) { return new (t || RecordSaveContinueAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(ModuleNavigation), i0.ɵɵinject(NotificationStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(RecentlyViewedService), i0.ɵɵinject(RecordPaginationService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordSaveContinueAction, factory: RecordSaveContinueAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordSaveContinueAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: ModuleNavigation }, { type: NotificationStore }, { type: SystemConfigStore }, { type: RecentlyViewedService }, { type: RecordPaginationService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordActionManager extends BaseActionManager {
    constructor(edit, create, toggleWidgets, cancel, cancelCreate, save, saveNew, saveContinue, async) {
        super();
        this.edit = edit;
        this.create = create;
        this.toggleWidgets = toggleWidgets;
        this.cancel = cancel;
        this.cancelCreate = cancelCreate;
        this.save = save;
        this.saveNew = saveNew;
        this.saveContinue = saveContinue;
        this.async = async;
        edit.modes.forEach(mode => this.actions[mode][edit.key] = edit);
        create.modes.forEach(mode => this.actions[mode][create.key] = create);
        toggleWidgets.modes.forEach(mode => this.actions[mode][toggleWidgets.key] = toggleWidgets);
        cancel.modes.forEach(mode => this.actions[mode][cancel.key] = cancel);
        save.modes.forEach(mode => this.actions[mode][save.key] = save);
        saveNew.modes.forEach(mode => this.actions[mode][saveNew.key] = saveNew);
        saveContinue.modes.forEach(mode => this.actions[mode][saveContinue.key] = saveContinue);
        cancelCreate.modes.forEach(mode => this.actions[mode][cancelCreate.key] = cancelCreate);
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
    }
    static { this.ɵfac = function RecordActionManager_Factory(t) { return new (t || RecordActionManager)(i0.ɵɵinject(RecordEditAction), i0.ɵɵinject(RecordCreateAction), i0.ɵɵinject(RecordToggleWidgetsAction), i0.ɵɵinject(RecordCancelAction), i0.ɵɵinject(CancelCreateAction), i0.ɵɵinject(RecordSaveAction), i0.ɵɵinject(RecordSaveNewAction), i0.ɵɵinject(RecordSaveContinueAction), i0.ɵɵinject(AsyncProcessRecordAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordActionManager, factory: RecordActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RecordEditAction }, { type: RecordCreateAction }, { type: RecordToggleWidgetsAction }, { type: RecordCancelAction }, { type: CancelCreateAction }, { type: RecordSaveAction }, { type: RecordSaveNewAction }, { type: RecordSaveContinueAction }, { type: AsyncProcessRecordAction }]; }, null); })();

class RecordActionDisplayTypeLogic extends ActionLogicHandler {
    constructor(activeFieldsChecker) {
        super();
        this.activeFieldsChecker = activeFieldsChecker;
        this.key = 'displayType';
        this.modes = ['edit', 'detail', 'list', 'create', 'massupdate', 'filter'];
    }
    runAll(displayLogic, data) {
        let toDisplay = true;
        const validModeLogic = Object.values(displayLogic).filter(logic => {
            const allowedModes = logic.modes ?? [];
            return !!(allowedModes.length && allowedModes.includes(data.store.getMode()));
        });
        if (!validModeLogic || !validModeLogic.length) {
            return toDisplay;
        }
        let defaultDisplay = data?.action?.display ?? 'show';
        let targetDisplay = 'hide';
        if (defaultDisplay === 'hide') {
            targetDisplay = 'show';
        }
        const isActive = validModeLogic.some(logic => this.run(data, logic));
        if (isActive) {
            defaultDisplay = targetDisplay;
        }
        toDisplay = (defaultDisplay === 'show');
        return toDisplay;
    }
    run(data, logic) {
        const record = data.store.recordStore.getStaging();
        if (!record || !logic) {
            return true;
        }
        const activeOnFields = (logic.params && logic.params.activeOnFields) || {};
        const relatedFields = Object.keys(activeOnFields);
        const activeOnAttributes = (logic.params && logic.params.activeOnAttributes) || {};
        const relatedAttributesFields = Object.keys(activeOnAttributes);
        if (!relatedFields.length && !relatedAttributesFields.length) {
            return true;
        }
        return this.activeFieldsChecker.isActive(relatedFields, record, activeOnFields, relatedAttributesFields, activeOnAttributes);
    }
    static { this.ɵfac = function RecordActionDisplayTypeLogic_Factory(t) { return new (t || RecordActionDisplayTypeLogic)(i0.ɵɵinject(ActiveFieldsChecker)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordActionDisplayTypeLogic, factory: RecordActionDisplayTypeLogic.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordActionDisplayTypeLogic, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: ActiveFieldsChecker }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, metadata, language, actionManager, asyncActionService, message, confirmation, selectModalService, displayTypeLogic, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.metadata = metadata;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.displayTypeLogic = displayTypeLogic;
        this.appMetadataStore = appMetadataStore;
        this.defaultActions = {
            detail: [
                {
                    key: 'toggle-widgets',
                    labelKey: 'LBL_INSIGHTS',
                    params: {
                        expanded: true
                    },
                    acl: []
                },
            ],
            edit: [
                {
                    key: 'toggle-widgets',
                    labelKey: 'LBL_INSIGHTS',
                    params: {
                        expanded: true
                    },
                    acl: []
                }
            ],
        };
    }
    getActions(context) {
        return this.metadata.recordViewMetadata$.pipe(combineLatestWith(this.store.mode$, this.store.record$, this.store.language$, this.store.widgets$, this.store.panels$), map(([meta, mode]) => {
            if (!mode || !meta) {
                return [];
            }
            return this.parseModeActions(meta.actions, mode, this.store.getViewContext());
        }));
    }
    buildActionData(action, context) {
        return {
            store: this.store,
            action,
        };
    }
    /**
     * Build backend process input
     *
     * @param {Action} action Action
     * @param {string} actionName Action Name
     * @param {string} moduleName Module Name
     * @param {ActionContext|null} context Context
     * @returns {AsyncActionInput} Built backend process input
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const baseRecord = this.store.getBaseRecord();
        this.message.removeMessages();
        return {
            action: actionName,
            module: baseRecord.module,
            id: baseRecord.id,
            params: (action && action.params) || []
        };
    }
    getMode() {
        return this.store.getMode();
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, context) {
        this.store.load(false).pipe(take(1)).subscribe();
    }
    shouldDisplay(actionHandler, data) {
        const displayLogic = data?.action?.displayLogic ?? null;
        let toDisplay = true;
        if (displayLogic && Object.keys(displayLogic).length) {
            toDisplay = this.displayTypeLogic.runAll(displayLogic, data);
        }
        if (!toDisplay) {
            return false;
        }
        return actionHandler && actionHandler.shouldDisplay(data);
    }
    static { this.ɵfac = function RecordActionsAdapter_Factory(t) { return new (t || RecordActionsAdapter)(i0.ɵɵinject(RecordViewStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(RecordActionDisplayTypeLogic), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordActionsAdapter, factory: RecordActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }, { type: LanguageStore }, { type: RecordActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: RecordActionDisplayTypeLogic }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordViewSidebarWidgetService {
    constructor(systemConfigStore, screenSize, store) {
        this.systemConfigStore = systemConfigStore;
        this.screenSize = screenSize;
        this.store = store;
        this.swapSizes = [];
        this.subs = [];
        this.swapSizes = this.systemConfigStore.getUi('widget_swap_screen_sizes');
        this.widgetSwap$ = this.screenSize.screenSize$.pipe(map(screenSize => {
            const swap = isTrue(this.swapSizes[screenSize] ?? false);
            if ((this.widgetSwap === null && swap === true) || (this.widgetSwap !== swap && swap === true)) {
                this.store.showSidebarWidgets = false;
            }
            this.widgetSwap = swap;
            return swap;
        }));
    }
    destroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
    }
    static { this.ɵfac = function RecordViewSidebarWidgetService_Factory(t) { return new (t || RecordViewSidebarWidgetService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(ScreenSizeObserverService), i0.ɵɵinject(RecordViewStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordViewSidebarWidgetService, factory: RecordViewSidebarWidgetService.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordViewSidebarWidgetService, [{
        type: Injectable
    }], function () { return [{ type: SystemConfigStore }, { type: ScreenSizeObserverService }, { type: RecordViewStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SidebarWidgetAdapter {
    constructor(store, metadata) {
        this.store = store;
        this.metadata = metadata;
        this.config$ = this.metadata.recordViewMetadata$.pipe(combineLatestWith(this.store.showSidebarWidgets$), map(([metadata, show]) => {
            if (metadata.sidebarWidgets && metadata.sidebarWidgets.length) {
                metadata.sidebarWidgets.forEach(widget => {
                    if (widget && widget.refreshOn === 'data-update') {
                        widget.reload$ = this.store.record$.pipe(map(() => true));
                    }
                    if (widget) {
                        widget.subpanelReload$ = this.store.subpanelReload$;
                    }
                });
            }
            return {
                widgets: metadata.sidebarWidgets || [],
                show
            };
        }));
    }
    static { this.ɵfac = function SidebarWidgetAdapter_Factory(t) { return new (t || SidebarWidgetAdapter)(i0.ɵɵinject(RecordViewStore), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SidebarWidgetAdapter, factory: SidebarWidgetAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarWidgetAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordContentAdapter {
    constructor(store, metadata, language, actions, logicManager) {
        this.store = store;
        this.metadata = metadata;
        this.language = language;
        this.actions = actions;
        this.logicManager = logicManager;
        this.fieldSubs = [];
        this.recordValidationHandler = inject(RecordValidationHandler);
    }
    getEditAction() {
        const data = {
            store: this.store
        };
        const action = {
            key: 'edit'
        };
        this.actions.run(action, this.store.getMode(), data);
    }
    getDisplayConfig() {
        return this.metadata.recordViewMetadata$.pipe(combineLatestWith(this.store.mode$), map(([meta, mode]) => {
            const layout = this.getLayout(meta);
            const maxColumns = meta.templateMeta.maxColumns || 2;
            const tabDefs = meta.templateMeta.tabDefs;
            return {
                layout,
                mode,
                maxColumns,
                tabDefs
            };
        }));
    }
    getPanels() {
        return this.store.panels$;
    }
    getRecord() {
        return this.store.stagingRecord$.pipe(combineLatestWith(this.store.mode$), map(([record, mode]) => {
            if (mode === 'edit' || mode === 'create') {
                this.recordValidationHandler.initValidators(record);
            }
            else {
                this.recordValidationHandler.resetValidators(record);
            }
            if (record.formGroup) {
                record.formGroup.enable();
            }
            return record;
        }));
    }
    getLayout(recordMeta) {
        let layout = 'panels';
        if (recordMeta.templateMeta.useTabs) {
            layout = 'tabs';
        }
        return layout;
    }
    clean() {
        this.fieldSubs.forEach(sub => sub.unsubscribe());
    }
    static { this.ɵfac = function RecordContentAdapter_Factory(t) { return new (t || RecordContentAdapter)(i0.ɵɵinject(RecordViewStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordActionManager), i0.ɵɵinject(PanelLogicManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordContentAdapter, factory: RecordContentAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContentAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }, { type: LanguageStore }, { type: RecordActionManager }, { type: PanelLogicManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TopWidgetAdapter {
    constructor(store, metadata) {
        this.store = store;
        this.metadata = metadata;
        this.config$ = this.metadata.recordViewMetadata$.pipe(combineLatestWith(this.store.showTopWidget$), map(([metadata, show]) => {
            if (metadata.topWidget && metadata.topWidget.refreshOn === 'data-update') {
                metadata.topWidget.reload$ = this.store.record$.pipe(map(() => true));
            }
            return {
                widget: metadata.topWidget,
                show
            };
        }));
    }
    static { this.ɵfac = function TopWidgetAdapter_Factory(t) { return new (t || TopWidgetAdapter)(i0.ɵɵinject(RecordViewStore), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TopWidgetAdapter, factory: TopWidgetAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TopWidgetAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BottomWidgetAdapter {
    constructor(store, metadata) {
        this.store = store;
        this.metadata = metadata;
        this.config$ = this.metadata.recordViewMetadata$.pipe(combineLatestWith(this.store.widgets$), map(([metadata, show]) => {
            if (metadata.bottomWidgets && metadata.bottomWidgets.length) {
                metadata.bottomWidgets.forEach(widget => {
                    if (widget && widget.refreshOn === 'data-update') {
                        widget.reload$ = this.store.record$.pipe(map(() => true));
                    }
                    if (widget) {
                        widget.subpanelReload$ = this.store.subpanelReload$;
                    }
                });
            }
            return {
                widgets: metadata.bottomWidgets || [],
                show
            };
        }));
    }
    static { this.ɵfac = function BottomWidgetAdapter_Factory(t) { return new (t || BottomWidgetAdapter)(i0.ɵɵinject(RecordViewStore), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BottomWidgetAdapter, factory: BottomWidgetAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BottomWidgetAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordViewStore }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState$1 = {
    paginationEnabled: false,
    recordIds: null,
    pagination: null
};
class RecordPaginationStore {
    constructor(preferences, systemConfigStore, listStoreFactory, localStorageService, recordPaginationService) {
        this.preferences = preferences;
        this.systemConfigStore = systemConfigStore;
        this.listStoreFactory = listStoreFactory;
        this.localStorageService = localStorageService;
        this.recordPaginationService = recordPaginationService;
        this.internalState = deepClone(initialState$1);
        this.cache$ = null;
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subs = [];
        this.recordListStore = this.listStoreFactory.create();
        this.recordIds$ = this.state$.pipe(map(state => state.recordIds), distinctUntilChanged());
        this.pagination$ = this.state$.pipe(map(state => state.pagination), distinctUntilChanged());
        this.paginationEnabled$ = this.state$.pipe(map(state => state.paginationEnabled), distinctUntilChanged());
    }
    clear() {
        this.cache$ = null;
        this.updateState(deepClone(initialState$1));
        this.subs.forEach(sub => sub.unsubscribe());
    }
    init() {
        const module = this.getModule();
        this.recordListStore.init(module, false);
        this.enableRecordPagination();
        this.loadDataLocalStorage();
        this.loadCurrentPagination(module);
        this.loadCurrentSort(module);
        this.loadCurrentFilter(module);
    }
    enableRecordPagination() {
        let isEnabled = this.systemConfigStore.getConfigValue('enable_record_pagination');
        if (isEnabled === "") {
            isEnabled = false;
        }
        this.updateState({ ...this.internalState, paginationEnabled: !!(isEnabled ?? false) });
    }
    loadDataLocalStorage() {
        const data = this.getRecordListPreference();
        this.updateState({ ...this.internalState, recordIds: data?.recordIds, pagination: data?.pagination });
    }
    getRecordListPreference() {
        const module = this.getModule();
        const data = this.loadPreference(module, 'current-record-pagination');
        this.checkPaginationExist(data);
        if (!isArray(data.recordIds) || !data.recordIds || !data.recordIds.length) {
            return null;
        }
        return data;
    }
    checkPaginationExist(data) {
        const module = this.getModule();
        const hasPagination = this.loadPreference(module, 'current-pagination', 'listview');
        if (!hasPagination) {
            this.recordListStore.pagination = data.pagination;
        }
    }
    loadPreference(module, storageKey, pageKey) {
        if (!pageKey) {
            return this.preferences.getUi(module, this.getPreferenceKey(storageKey));
        }
        return this.preferences.getUi(module, (pageKey + '-' + storageKey));
    }
    getPreferenceKey(storageKey) {
        return 'recordview-' + storageKey;
    }
    loadCurrentPagination(module) {
        const key = module + '-' + 'listview-current-pagination';
        const currentPagination = this.localStorageService.get(key);
        if (!currentPagination || emptyObject(currentPagination)) {
            return;
        }
        this.recordListStore.pagination = currentPagination;
    }
    loadCurrentSort(module) {
        const currentSort = this.loadPreference(module, 'current-sort', 'listview');
        if (!currentSort || emptyObject(currentSort)) {
            return;
        }
        this.recordListStore.sort = currentSort;
    }
    loadCurrentFilter(module) {
        const activeFiltersPref = this.loadPreference(module, 'current-filters', 'listview') ?? {};
        if (!activeFiltersPref || emptyObject(activeFiltersPref)) {
            return;
        }
        let currentSort = this.loadPreference(module, 'current-sort', 'listview');
        if (!currentSort && emptyObject(currentSort)) {
            currentSort = null;
        }
        this.setFilters(activeFiltersPref, false, currentSort);
    }
    setFilters(filters, reload = true, sort = null) {
        const filterKey = Object.keys(filters).shift();
        const filter = filters[filterKey];
        this.recordListStore.setFilters(filters, reload, sort);
        if (filter.criteria) {
            let orderBy = filter.criteria.orderBy ?? '';
            const sortOrder = filter.criteria.sortOrder ?? '';
            let direction = this.recordListStore.mapSortOrder(sortOrder);
            if (sort !== null) {
                orderBy = sort.orderBy;
                direction = sort.sortOrder;
            }
            this.recordListStore.updateSorting(orderBy, direction, false);
        }
        this.updateSearchCriteria(filters, reload);
    }
    updateSearchCriteria(filters, reload = true) {
        let criteria = this.mergeCriteria(filters);
        this.recordListStore.updateSearchCriteria(criteria, reload);
    }
    mergeCriteria(filters) {
        let criteria = {};
        const keys = Object.keys(filters ?? {}) ?? [];
        keys.forEach(key => {
            const filter = filters[key] ?? null;
            const filterCriteria = filter?.criteria ?? null;
            const filterCriteriaKeys = Object.keys(filterCriteria?.filters ?? {});
            if (filterCriteria === null || (filterCriteriaKeys && !filterCriteriaKeys.length)) {
                return;
            }
            if (emptyObject(criteria)) {
                criteria = deepClone(filterCriteria);
                return;
            }
            filterCriteriaKeys.forEach(criteriaKey => {
                const filterCriteriaContent = filterCriteria?.filters[criteriaKey] ?? null;
                const criteriaContent = criteria?.filters[criteriaKey] ?? null;
                if (!filterCriteriaContent) {
                    return;
                }
                const criteriaOperator = criteriaContent?.operator ?? null;
                if (!criteriaContent || !criteriaOperator) {
                    criteria.filters[criteriaKey] = deepClone(filterCriteriaContent);
                    return;
                }
                const filterCriteriaOperator = filterCriteriaContent?.operator ?? null;
                if (filterCriteriaOperator !== criteriaOperator || filterCriteriaOperator !== '=') {
                    delete criteria.filters[criteriaKey];
                    return;
                }
                criteriaContent.values = union(criteriaContent.values ?? [], filterCriteriaContent.values ?? []);
            });
        });
        return criteria;
    }
    getModule() {
        return this.recordPaginationService.getModule();
    }
    getCurrentPage() {
        const pageSize = this.internalState.pagination?.pageSize;
        const pageLast = this.internalState.pagination?.pageLast;
        const currentPage = Math.ceil(pageLast / pageSize);
        return currentPage;
    }
    getPageSize() {
        return this.internalState.pagination?.pageSize;
    }
    getRecordsCount() {
        return this.internalState.pagination?.total;
    }
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    set(state) {
        this.cache$ = of(state).pipe(shareReplay(1));
        this.updateState(state);
    }
    isCached() {
        return this.cache$ !== null;
    }
    static { this.ɵfac = function RecordPaginationStore_Factory(t) { return new (t || RecordPaginationStore)(i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(RecordListStoreFactory), i0.ɵɵinject(LocalStorageService), i0.ɵɵinject(RecordPaginationService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPaginationStore, factory: RecordPaginationStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPaginationStore, [{
        type: Injectable
    }], function () { return [{ type: UserPreferenceStore }, { type: SystemConfigStore }, { type: RecordListStoreFactory }, { type: LocalStorageService }, { type: RecordPaginationService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2024 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordPaginationComponent_div_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-button", 3);
    i0.ɵɵelementStart(2, "span", 4);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(4, "scrm-button", 3);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r2.prevButton);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate3(" ", ctx_r2.currentIndex, " ", vm_r1.appStrings["LBL_LIST_OF"] || "", " ", vm_r1.pageCount.total, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r2.nextButton);
} }
function RecordPaginationComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵtemplate(1, RecordPaginationComponent_div_0_ng_container_1_Template, 5, 5, "ng-container", 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.paginationEnabled);
} }
class RecordPaginationComponent {
    constructor(systemConfigStore, preferences, localStorageService, languageStore, navigation, nameMapper, recordViewStore, recordPaginationStore, recordPaginationService, route, router, modalService) {
        this.systemConfigStore = systemConfigStore;
        this.preferences = preferences;
        this.localStorageService = localStorageService;
        this.languageStore = languageStore;
        this.navigation = navigation;
        this.nameMapper = nameMapper;
        this.recordViewStore = recordViewStore;
        this.recordPaginationStore = recordPaginationStore;
        this.recordPaginationService = recordPaginationService;
        this.route = route;
        this.router = router;
        this.modalService = modalService;
        this.currentIndex = 1;
        this.currentPage = 1;
        this.pageSize = 20;
        this.totalRecordsCount = 0;
        this.isRecordsLoading = false;
        this.isSaveContinueClicked = false;
        this.mode = 'detail';
        this.paginationType = PaginationType.PAGINATION;
        this.subs = [];
        this.prevButton = null;
        this.nextButton = null;
        this.appStrings$ = this.languageStore.appStrings$;
        this.recordIds$ = this.recordPaginationStore.recordIds$;
        this.mode$ = this.recordViewStore.mode$;
        this.vm$ = null;
        this.subs.push(this.route.queryParamMap
            .subscribe((params) => {
            this.currentIndex = toNumber(params.get('offset'));
        }));
    }
    ngOnInit() {
        this.recordPaginationStore.init();
        this.currentPage = this.recordPaginationStore.getCurrentPage();
        this.pageSize = this.recordPaginationStore.getPageSize();
        this.totalRecordsCount = this.recordPaginationStore.getRecordsCount();
        this.paginationType = this.preferences.getUserPreference('listview_pagination_type') ?? this.systemConfigStore.getConfigValue('listview_pagination_type');
        this.recordPaginationService.paginationType = this.paginationType;
        this.subs.push(this.mode$.subscribe(mode => {
            this.mode = mode;
        }));
        this.prevButton = {
            klass: {
                'record-pagination-button': true,
                'pagination-previous': true,
                disabled: this.currentIndex === 1
            },
            icon: 'paginate_previous',
            iconKlass: 'sicon-2x',
            disabled: this.currentIndex === 1 || this.isRecordsLoading,
            onClick: () => this.prevRecord()
        };
        this.nextButton = {
            klass: {
                'record-pagination-button': true,
                'pagination-next': true,
                disabled: this.currentIndex === this.totalRecordsCount
            },
            icon: 'paginate_next',
            iconKlass: 'sicon-2x',
            disabled: this.currentIndex === this.totalRecordsCount || this.isRecordsLoading,
            onClick: () => this.nextRecord()
        };
        this.vm$ = this.appStrings$.pipe(combineLatestWith(this.recordPaginationStore.pagination$, this.recordPaginationStore.paginationEnabled$), map(([appStrings, pageCount, paginationEnabled]) => {
            const module = this.nameMapper.toFrontend(this.recordPaginationStore.getModule()) ?? '';
            const key = module + '-' + 'recordview-current-record-pagination';
            const isRecordPaginationExist = this.localStorageService.get(key);
            const isRecordValid = this.recordPaginationService.checkRecordValid(this.recordViewStore.getRecordId());
            if (!isRecordPaginationExist || !isRecordValid || (this.currentIndex > this.totalRecordsCount)) {
                paginationEnabled = false;
            }
            this.prevButton = { ...this.prevButton, titleKey: appStrings['LBL_SEARCH_PREV'] || '' };
            this.nextButton = { ...this.nextButton, titleKey: appStrings['LBL_SEARCH_NEXT'] || '' };
            return { appStrings, pageCount, paginationEnabled };
        }));
        this.subs.push(this.recordIds$.subscribe(recordIds => {
            this.recordIds = recordIds;
        }));
        this.subs.push(this.recordPaginationService.nextRecord$.pipe(filter(data => {
            if (!data) {
                return false;
            }
            return true;
        }), tap((data) => {
            this.isSaveContinueClicked = true;
            this.nextRecord();
        })).subscribe((data) => {
            this.isSaveContinueClicked = false;
            this.recordPaginationService.triggerNextRecord(false);
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.recordPaginationStore.clear();
    }
    prevRecord() {
        if (this.currentIndex <= 0) {
            return;
        }
        let nextRecordIndex = (this.currentIndex - 2) % this.pageSize;
        let nextPageThreshold = this.currentIndex - ((this.currentPage - 1) * this.pageSize) - 1;
        if (nextPageThreshold <= 0) {
            this.loadPage(PageSelection.PREVIOUS);
        }
        else {
            if (this.mode === 'edit' && this.recordViewStore.recordStore.isDirty()) {
                this.showConfirmationModal(PageSelection.PREVIOUS, nextRecordIndex);
            }
            else {
                this.navigatePrevRoute(nextRecordIndex);
            }
        }
    }
    nextRecord() {
        if (this.currentIndex >= this.totalRecordsCount) {
            return;
        }
        let nextRecordIndex = this.currentIndex % this.pageSize;
        let nextPageThreshold = this.currentIndex - ((this.currentPage - 1) * this.pageSize);
        if (nextPageThreshold > this.recordIds.length - 1) {
            this.loadPage(PageSelection.NEXT);
        }
        else {
            if (this.mode === 'edit' && this.recordViewStore.recordStore.isDirty() && !this.isSaveContinueClicked) {
                this.showConfirmationModal(PageSelection.NEXT, nextRecordIndex);
            }
            else {
                this.navigateNextRoute(nextRecordIndex);
            }
        }
    }
    loadPage(direction) {
        this.isRecordsLoading = true;
        let nextRecordIndex = 0;
        let isPaginationLoadMore = false;
        if (this.paginationType === PaginationType.LOAD_MORE) {
            isPaginationLoadMore = true;
        }
        if (direction === PageSelection.PREVIOUS) {
            nextRecordIndex = this.pageSize - 1;
        }
        else if (direction === PageSelection.NEXT && isPaginationLoadMore) {
            nextRecordIndex = this.currentIndex;
        }
        if (isPaginationLoadMore && direction !== PageSelection.PREVIOUS) {
            const jump = this.preferences.getUserPreference('list_max_entries_per_page') ?? this.systemConfigStore.getConfigValue('list_max_entries_per_page');
            const pagination = this.recordPaginationStore.recordListStore.getPagination();
            const currentPageSize = pagination.pageSize || 0;
            const newPageSize = Number(currentPageSize) + Number(jump);
            this.recordPaginationStore.recordListStore.setPageSize(newPageSize);
            this.recordPaginationStore.recordListStore.updatePagination(pagination.current);
        }
        this.recordPaginationStore.recordListStore.setPage(direction, isPaginationLoadMore).subscribe(data => {
            this.recordPaginationService.updateRecordListLocalStorage(data.records, data.pagination);
            this.recordPaginationStore.loadDataLocalStorage();
            this.isRecordsLoading = false;
            if (this.mode === 'edit' && this.recordViewStore.recordStore.isDirty() && !this.isSaveContinueClicked) {
                this.showConfirmationModal(direction, nextRecordIndex);
            }
            else {
                direction === PageSelection.NEXT ? this.navigateNextRoute(nextRecordIndex) : this.navigatePrevRoute(nextRecordIndex);
            }
        });
    }
    navigateNextRoute(nextRecordIndex) {
        const nextRoute = this.buildRoute(this.recordIds[nextRecordIndex]);
        this.router.navigate([nextRoute], { queryParams: { offset: this.currentIndex + 1 } });
    }
    navigatePrevRoute(nextRecordIndex) {
        const nextRoute = this.buildRoute(this.recordIds[nextRecordIndex]);
        this.router.navigate([nextRoute], { queryParams: { offset: this.currentIndex - 1 } });
    }
    showConfirmationModal(direction, nextRecordIndex) {
        const modal = this.modalService.open(MessageModalComponent);
        modal.componentInstance.textKey = 'WARN_UNSAVED_CHANGES';
        modal.componentInstance.buttons = [
            {
                labelKey: 'LBL_CANCEL',
                klass: ['btn-secondary'],
                onClick: activeModal => activeModal.dismiss()
            },
            {
                labelKey: 'LBL_PROCEED',
                klass: ['btn-main'],
                onClick: activeModal => {
                    direction === PageSelection.NEXT ? this.navigateNextRoute(nextRecordIndex) : this.navigatePrevRoute(nextRecordIndex);
                    activeModal.close();
                }
            }
        ];
    }
    buildRoute(recordId) {
        const module = this.nameMapper.toFrontend(this.recordPaginationStore.getModule()) ?? '';
        const id = recordId.id ?? '';
        const isEdit = this.mode === 'edit';
        return this.navigation.getRecordRouterLink(module, id, isEdit);
    }
    static { this.ɵfac = function RecordPaginationComponent_Factory(t) { return new (t || RecordPaginationComponent)(i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(UserPreferenceStore), i0.ɵɵdirectiveInject(LocalStorageService), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(ModuleNameMapper), i0.ɵɵdirectiveInject(RecordViewStore), i0.ɵɵdirectiveInject(RecordPaginationStore), i0.ɵɵdirectiveInject(RecordPaginationService), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(i3$1.NgbModal)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordPaginationComponent, selectors: [["scrm-record-pagination"]], standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 2, vars: 3, consts: [["class", "record-pagination-container d-flex align-items-center justify-content-end", 4, "ngIf"], [1, "record-pagination-container", "d-flex", "align-items-center", "justify-content-end"], [4, "ngIf"], [3, "config"], [1, "pagination-count"]], template: function RecordPaginationComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordPaginationComponent_div_0_Template, 2, 1, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [CommonModule, i2.NgIf, i2.AsyncPipe, ButtonModule, ButtonComponent], encapsulation: 2, changeDetection: 0 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPaginationComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-pagination', standalone: true, imports: [CommonModule, ButtonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2024 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"record-pagination-container d-flex align-items-center justify-content-end\" *ngIf=\"(vm$ | async) as vm\">\n    <ng-container *ngIf=\"vm.paginationEnabled\">\n        <scrm-button [config]=\"prevButton\"></scrm-button>\n        <span class=\"pagination-count\">\n            {{currentIndex}} {{vm.appStrings['LBL_LIST_OF'] || ''}} {{vm.pageCount.total}}\n        </span>\n        <scrm-button [config]=\"nextButton\"></scrm-button>\n    </ng-container>\n</div>\n" }]
    }], function () { return [{ type: SystemConfigStore }, { type: UserPreferenceStore }, { type: LocalStorageService }, { type: LanguageStore }, { type: ModuleNavigation }, { type: ModuleNameMapper }, { type: RecordViewStore }, { type: RecordPaginationStore }, { type: RecordPaginationService }, { type: i1$2.ActivatedRoute }, { type: i1$2.Router }, { type: i3$1.NgbModal }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordContainerComponent_div_0_ng_container_2_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7)(1, "div", 11)(2, "div", 12);
    i0.ɵɵelement(3, "div", 13);
    i0.ɵɵelementEnd()()();
} }
function RecordContainerComponent_div_0_ng_container_2_ng_container_4_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7)(1, "div", 11);
    i0.ɵɵelement(2, "scrm-top-widget", 14);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(3).ngIf;
    const ctx_r10 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", vm_r1.topWidgetConfig.widget)("context", ctx_r10.getViewContext())("type", vm_r1.topWidgetConfig.widget.type);
} }
function RecordContainerComponent_div_0_ng_container_2_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContainerComponent_div_0_ng_container_2_ng_container_4_div_1_Template, 3, 3, "div", 6);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.topWidgetConfig.show && ctx_r5.hasTopWidgetMetadata(vm_r1.topWidgetConfig.widget));
} }
function RecordContainerComponent_div_0_ng_container_2_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "scrm-record-content-skeleton");
    i0.ɵɵelementContainerEnd();
} }
function RecordContainerComponent_div_0_ng_container_2_ng_container_8_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 17);
    i0.ɵɵelement(1, "scrm-record-pagination");
    i0.ɵɵelementEnd();
} }
function RecordContainerComponent_div_0_ng_container_2_ng_container_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "scrm-record-content", 15);
    i0.ɵɵtemplate(2, RecordContainerComponent_div_0_ng_container_2_ng_container_8_div_2_Template, 2, 0, "div", 16);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("dataSource", ctx_r7.getContentAdapter());
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.isOffsetExist);
} }
function RecordContainerComponent_div_0_ng_container_2_div_9_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 20);
    i0.ɵɵelement(1, "scrm-sidebar-widget", 21);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const widget_r15 = ctx.$implicit;
    const ctx_r14 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", widget_r15)("context$", ctx_r14.getViewContext$())("context", ctx_r14.getViewContext())("type", widget_r15.type);
} }
function RecordContainerComponent_div_0_ng_container_2_div_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18)(1, "div", 8);
    i0.ɵɵtemplate(2, RecordContainerComponent_div_0_ng_container_2_div_9_div_2_Template, 2, 4, "div", 19);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", vm_r1.bottomWidgetConfig.widgets);
} }
function RecordContainerComponent_div_0_ng_container_2_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 22)(1, "div", 8);
    i0.ɵɵelement(2, "scrm-subpanel-container", 23);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("config", ctx_r9.getSubpanelsConfig());
} }
const _c0$2 = function (a0) { return { "col-lg-12": a0 }; };
function RecordContainerComponent_div_0_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 4)(2, "div", 5);
    i0.ɵɵtemplate(3, RecordContainerComponent_div_0_ng_container_2_div_3_Template, 4, 0, "div", 6);
    i0.ɵɵtemplate(4, RecordContainerComponent_div_0_ng_container_2_ng_container_4_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelementStart(5, "div", 7)(6, "div", 8);
    i0.ɵɵtemplate(7, RecordContainerComponent_div_0_ng_container_2_ng_container_7_Template, 2, 0, "ng-container", 3);
    i0.ɵɵtemplate(8, RecordContainerComponent_div_0_ng_container_2_ng_container_8_Template, 3, 2, "ng-container", 3);
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(9, RecordContainerComponent_div_0_ng_container_2_div_9_Template, 3, 1, "div", 9);
    i0.ɵɵtemplate(10, RecordContainerComponent_div_0_ng_container_2_div_10_Template, 3, 1, "div", 10);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(7, _c0$2, !ctx_r2.sidebarWidgetConfig.show));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r2.loading);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r2.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r2.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.bottomWidgetConfig.show && vm_r1.bottomWidgetConfig.widgets);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.showSubpanels);
} }
function RecordContainerComponent_div_0_ng_container_3_div_1_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 20);
    i0.ɵɵelement(1, "scrm-sidebar-widget", 26);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const widget_r20 = ctx.$implicit;
    const ctx_r19 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("type", widget_r20.type)("context", ctx_r19.getViewContext())("context$", ctx_r19.getViewContext$())("config", widget_r20);
} }
function RecordContainerComponent_div_0_ng_container_3_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 25);
    i0.ɵɵtemplate(1, RecordContainerComponent_div_0_ng_container_3_div_1_div_1_Template, 2, 4, "div", 19);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r18 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("mt-0", ctx_r18.swapWidgets);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r18.sidebarWidgetConfig.widgets);
} }
function RecordContainerComponent_div_0_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, RecordContainerComponent_div_0_ng_container_3_div_1_Template, 2, 3, "div", 24);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r3.displayWidgets);
} }
function RecordContainerComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 2);
    i0.ɵɵtemplate(2, RecordContainerComponent_div_0_ng_container_2_Template, 11, 9, "ng-container", 3);
    i0.ɵɵtemplate(3, RecordContainerComponent_div_0_ng_container_3_Template, 2, 1, "ng-container", 3);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !ctx_r0.swapWidgets || ctx_r0.swapWidgets && !ctx_r0.displayWidgets);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.swapWidgets || ctx_r0.swapWidgets && ctx_r0.displayWidgets);
} }
class RecordContainerComponent {
    onEnterKey() {
        if (!this.saveAction || !this.context) {
            return;
        }
        this.actionsAdapter.runAction(this.saveAction, this.context);
    }
    constructor(recordViewStore, language, metadata, contentAdapter, topWidgetAdapter, sidebarWidgetAdapter, bottomWidgetAdapter, actionsAdapter, sidebarWidgetHandler, activatedRoute) {
        this.recordViewStore = recordViewStore;
        this.language = language;
        this.metadata = metadata;
        this.contentAdapter = contentAdapter;
        this.topWidgetAdapter = topWidgetAdapter;
        this.sidebarWidgetAdapter = sidebarWidgetAdapter;
        this.bottomWidgetAdapter = bottomWidgetAdapter;
        this.actionsAdapter = actionsAdapter;
        this.sidebarWidgetHandler = sidebarWidgetHandler;
        this.activatedRoute = activatedRoute;
        this.subs = [];
        this.loading = true;
        this.language$ = this.language.vm$;
        this.isOffsetExist = false;
        this.displayWidgets = true;
        this.swapWidgets = false;
        this.vm$ = this.language$.pipe(combineLatestWith(this.bottomWidgetAdapter.config$, this.topWidgetAdapter.config$, this.recordViewStore.showSubpanels$), map(([language, bottomWidgetConfig, topWidgetConfig, showSubpanels]) => ({
            language,
            bottomWidgetConfig,
            topWidgetConfig,
            showSubpanels
        })));
        this.actionConfig$ = this.recordViewStore.mode$.pipe(combineLatestWith(this.actionsAdapter.getActions(), this.getViewContext$()), filter(([mode, actions, context]) => mode === 'edit'), map(([mode, actions, context]) => ({
            mode,
            actions,
            context
        })));
        const queryParams = this.activatedRoute.snapshot.queryParamMap;
        this.isOffsetExist = !!queryParams.get('offset');
    }
    ngOnInit() {
        this.subs.push(this.recordViewStore.loading$.subscribe(loading => {
            this.loading = loading;
        }));
        this.subs.push(this.actionConfig$.subscribe(config => {
            this.context = config.context;
            config.actions.forEach(actionItem => {
                if (actionItem.key === 'save') {
                    this.saveAction = actionItem;
                }
            });
        }));
        this.subs.push(this.sidebarWidgetAdapter.config$.subscribe(sidebarWidgetConfig => {
            this.sidebarWidgetConfig = sidebarWidgetConfig;
            this.displayWidgets = this.sidebarWidgetConfig.show && this.sidebarWidgetConfig.widgets;
        }));
        this.subs.push(this.sidebarWidgetHandler.widgetSwap$.subscribe(swap => {
            this.swapWidgets = swap;
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.contentAdapter.clean();
    }
    getContentAdapter() {
        return this.contentAdapter;
    }
    getSubpanelsConfig() {
        return {
            parentModule: this.recordViewStore.getModuleName(),
            subpanels$: this.recordViewStore.subpanels$,
            sidebarActive$: this.recordViewStore.widgets$
        };
    }
    getViewContext() {
        return this.recordViewStore.getViewContext();
    }
    getViewContext$() {
        return this.recordViewStore.viewContext$;
    }
    hasTopWidgetMetadata(meta) {
        return !!(meta && meta.type);
    }
    static { this.ɵfac = function RecordContainerComponent_Factory(t) { return new (t || RecordContainerComponent)(i0.ɵɵdirectiveInject(RecordViewStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(MetadataStore), i0.ɵɵdirectiveInject(RecordContentAdapter), i0.ɵɵdirectiveInject(TopWidgetAdapter), i0.ɵɵdirectiveInject(SidebarWidgetAdapter), i0.ɵɵdirectiveInject(BottomWidgetAdapter), i0.ɵɵdirectiveInject(RecordActionsAdapter), i0.ɵɵdirectiveInject(RecordViewSidebarWidgetService), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordContainerComponent, selectors: [["scrm-record-container"]], hostBindings: function RecordContainerComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("keyup.control.enter", function RecordContainerComponent_keyup_control_enter_HostBindingHandler() { return ctx.onEnterKey(); });
        } }, features: [i0.ɵɵProvidersFeature([RecordContentAdapter, TopWidgetAdapter, SidebarWidgetAdapter, BottomWidgetAdapter])], decls: 2, vars: 3, consts: [["class", "record-view-container view-container container-fluid pt-3 pb-3 small-font", 4, "ngIf"], [1, "record-view-container", "view-container", "container-fluid", "pt-3", "pb-3", "small-font"], [1, "row"], [4, "ngIf"], [1, "col-lg-9", 3, "ngClass"], [1, "container-fluid", "pl-0", "pr-0"], ["class", "row no-gutters", 4, "ngIf"], [1, "row", "no-gutters"], [1, "col"], ["class", "row no-gutters mt-4", 4, "ngIf"], ["class", "row no-gutters pt-1 pb-4", 4, "ngIf"], [1, "col", "pb-3"], [1, "d-flex", "justify-content-center", "widget-bar", "rounded", "pb-1", "pt-3", "box-loading"], [1, "d-flex", "justify-content-center", "align-items-baseline", "widget-bar-entry", "p-2"], [3, "config", "context", "type"], [3, "dataSource"], ["top-right-placement", "", 4, "ngIf"], ["top-right-placement", ""], [1, "row", "no-gutters", "mt-4"], ["class", "mb-3", 4, "ngFor", "ngForOf"], [1, "mb-3"], [3, "config", "context$", "context", "type"], [1, "row", "no-gutters", "pt-1", "pb-4"], [3, "config"], ["class", "col-lg-3 record-widget-container pl-0", 3, "mt-0", 4, "ngIf"], [1, "col-lg-3", "record-widget-container", "pl-0"], [3, "type", "context", "context$", "config"]], template: function RecordContainerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordContainerComponent_div_0_Template, 4, 2, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, SubpanelContainerComponent, RecordContentComponent, TopWidgetComponent, SidebarWidgetComponent, RecordContentSkeletonComponent, RecordPaginationComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContainerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-container', providers: [RecordContentAdapter, TopWidgetAdapter, SidebarWidgetAdapter, BottomWidgetAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start Record View Container Section -->\n\n<div *ngIf=\"(vm$ | async) as vm\"\n     class=\"record-view-container view-container container-fluid pt-3 pb-3 small-font\">\n    <div class=\"row\">\n        <ng-container *ngIf=\"!swapWidgets || (swapWidgets && !displayWidgets)\">\n            <div class=\"col-lg-9\" [ngClass]=\"{ 'col-lg-12': !sidebarWidgetConfig.show }\">\n\n            <div class=\"container-fluid pl-0 pr-0\">\n                <div *ngIf=\"loading\" class=\"row no-gutters\">\n                    <div class=\"col pb-3\">\n                        <div class=\"d-flex justify-content-center widget-bar rounded  pb-1 pt-3 box-loading\">\n                            <div class=\"d-flex justify-content-center align-items-baseline widget-bar-entry p-2\">\n                            </div>\n                        </div>\n                    </div>\n                </div>\n                <ng-container *ngIf=\"!loading\">\n                    <div *ngIf=\"vm.topWidgetConfig.show && hasTopWidgetMetadata(vm.topWidgetConfig.widget)\"\n                         class=\"row no-gutters\">\n                        <div class=\"col pb-3\">\n                            <scrm-top-widget [config]=\"vm.topWidgetConfig.widget\"\n                                             [context]=\"getViewContext()\"\n                                             [type]=\"vm.topWidgetConfig.widget.type\">\n                            </scrm-top-widget>\n                        </div>\n                    </div>\n                </ng-container>\n\n\n                <div class=\"row no-gutters\">\n                    <div class=\"col\">\n                        <ng-container *ngIf=\"loading\">\n                            <scrm-record-content-skeleton></scrm-record-content-skeleton>\n                        </ng-container>\n                        <ng-container *ngIf=\"!loading\">\n                            <scrm-record-content [dataSource]=\"getContentAdapter()\">\n                                <div top-right-placement *ngIf=\"isOffsetExist\">\n                                    <scrm-record-pagination></scrm-record-pagination>\n                                </div>\n                            </scrm-record-content>\n                        </ng-container>\n                    </div>\n                </div>\n\n                <div *ngIf=\"vm.bottomWidgetConfig.show && vm.bottomWidgetConfig.widgets\"\n                     class=\"row no-gutters mt-4\">\n                    <div class=\"col\">\n                        <div *ngFor=\"let widget of vm.bottomWidgetConfig.widgets\" class=\"mb-3\">\n                            <scrm-sidebar-widget [config]=\"widget\"\n                                                 [context$]=\"getViewContext$()\"\n                                                 [context]=\"getViewContext()\"\n                                                 [type]=\"widget.type\">\n                            </scrm-sidebar-widget>\n                        </div>\n                    </div>\n                </div>\n\n                <div *ngIf=\"vm.showSubpanels\"\n                     class=\"row no-gutters pt-1 pb-4\">\n                    <div class=\"col\">\n                        <scrm-subpanel-container [config]=\"getSubpanelsConfig()\"></scrm-subpanel-container>\n                    </div>\n                </div>\n            </div>\n        </div>\n        </ng-container>\n\n        <ng-container *ngIf=\"!swapWidgets || (swapWidgets && displayWidgets)\">\n            <div class=\"col-lg-3 record-widget-container pl-0\"\n                 [class.mt-0]=\"swapWidgets\"\n                 *ngIf=\"displayWidgets\">\n                <div class=\"mb-3\" *ngFor=\"let widget of sidebarWidgetConfig.widgets\">\n                    <scrm-sidebar-widget [type]=\"widget.type\"\n                                         [context]=\"getViewContext()\"\n                                         [context$]=\"getViewContext$()\"\n                                         [config]=\"widget\">\n                    </scrm-sidebar-widget>\n                </div>\n            </div>\n        </ng-container>\n\n    </div>\n</div>\n\n<!-- End Record View Container Section -->\n" }]
    }], function () { return [{ type: RecordViewStore }, { type: LanguageStore }, { type: MetadataStore }, { type: RecordContentAdapter }, { type: TopWidgetAdapter }, { type: SidebarWidgetAdapter }, { type: BottomWidgetAdapter }, { type: RecordActionsAdapter }, { type: RecordViewSidebarWidgetService }, { type: i1$2.ActivatedRoute }]; }, { onEnterKey: [{
            type: HostListener,
            args: ['keyup.control.enter']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function RecordHeaderComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3)(1, "div", 4);
    i0.ɵɵelement(2, "scrm-module-title", 5)(3, "div", 6);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("title", ctx_r0.moduleTitle);
} }
function RecordHeaderComponent_div_3_div_3_scrm_button_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button", 20);
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("config", ctx_r6.backButtonConfig);
} }
function RecordHeaderComponent_div_3_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵtemplate(1, RecordHeaderComponent_div_3_div_3_scrm_button_1_Template, 1, 1, "scrm-button", 19);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.backButtonConfig);
} }
function RecordHeaderComponent_div_3_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 21);
    i0.ɵɵelement(1, "scrm-favorite-toggle", 22);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("record", ctx_r3.record);
} }
function RecordHeaderComponent_div_3_scrm_dynamic_label_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-dynamic-label", 23);
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("fields", ctx_r4.record.fields)("labelKey", ctx_r4.getSummaryTemplate());
} }
function RecordHeaderComponent_div_3_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 24);
    i0.ɵɵelement(1, "scrm-action-group-menu", 25);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r5.actionsAdapter)("actionContext", ctx_r5.getActionContext(ctx_r5.record))("klass", ctx_r5.isScrolled ? "record-view-actions-scrolled float-right" : "record-view-actions float-right");
} }
function RecordHeaderComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7)(1, "div", 8)(2, "div", 9);
    i0.ɵɵtemplate(3, RecordHeaderComponent_div_3_div_3_Template, 2, 1, "div", 10);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "div", 11)(5, "div", 12);
    i0.ɵɵtemplate(6, RecordHeaderComponent_div_3_div_6_Template, 2, 1, "div", 13);
    i0.ɵɵtemplate(7, RecordHeaderComponent_div_3_scrm_dynamic_label_7_Template, 1, 2, "scrm-dynamic-label", 14);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(8, "div", 15)(9, "div", 16);
    i0.ɵɵtemplate(10, RecordHeaderComponent_div_3_div_10_Template, 2, 3, "div", 17);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r1.mode === "detail" || ctx_r1.mode === "edit");
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("justify-content-center", ctx_r1.mode === "detail" || ctx_r1.mode === "edit")("justify-content-start", !(ctx_r1.mode === "detail" || ctx_r1.mode === "edit"))("record-view-name-wrapper-margin-left", ctx_r1.mode === "detail" || ctx_r1.mode === "edit");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r1.isScrolled ? "record-view-name-scrolled" : "record-view-name");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.record && ctx_r1.record.fields && ctx_r1.mode !== "create");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.record && ctx_r1.record.fields);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r1.record);
} }
class RecordHeaderComponent {
    onScroll() {
        const scrollPosition = window.pageYOffset;
        //ScrollThreshold is set to 1em
        const scrollThreshold = parseFloat(getComputedStyle(document.documentElement).fontSize);
        if (scrollPosition > scrollThreshold) {
            //5 is just a random safezone number
            if (scrollPosition - scrollThreshold < 5)
                return;
            this.isScrolled = true;
        }
        else {
            if (scrollThreshold - scrollPosition < 5)
                return;
            this.isScrolled = false;
        }
    }
    constructor(actionsAdapter, recordViewStore, moduleNavigation, appState, router) {
        this.actionsAdapter = actionsAdapter;
        this.recordViewStore = recordViewStore;
        this.moduleNavigation = moduleNavigation;
        this.appState = appState;
        this.router = router;
        this.mode = 'detail';
        this.loading = true;
        this.isScrolled = false;
        this.subs = [];
    }
    ngOnInit() {
        this.mode = this.recordViewStore.getMode();
        this.setBackButtonConfig();
        this.subs.push(this.recordViewStore.mode$.subscribe(mode => {
            this.mode = mode;
        }));
        this.subs.push(this.recordViewStore.record$.subscribe(record => {
            this.record = record;
        }));
        this.subs.push(this.recordViewStore.loading$.subscribe(loading => {
            this.loading = loading;
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
    }
    get moduleTitle() {
        const module = this.recordViewStore.vm.appData.module;
        const appListStrings = this.recordViewStore.vm.appData.language.appListStrings;
        return this.moduleNavigation.getModuleLabel(module, appListStrings);
    }
    /**
     * Get Summary template
     *
     * @returns {string} template label
     */
    getSummaryTemplate() {
        return this.recordViewStore.getSummaryTemplate();
    }
    /**
     * Build action context
     * @param record
     */
    getActionContext(record) {
        if (!record) {
            return {};
        }
        return {
            module: record.module || '',
            record
        };
    }
    setBackButtonConfig() {
        const moduleRoute = this.moduleNavigation.getModuleRoute(this.recordViewStore.vm.appData.module);
        this.backButtonConfig = {
            icon: 'paginate_previous',
            klass: 'back-button',
            onClick: () => {
                this.router.navigate([moduleRoute.route], { queryParams: { keepPagination: true } }).then();
            }
        };
    }
    static { this.ɵfac = function RecordHeaderComponent_Factory(t) { return new (t || RecordHeaderComponent)(i0.ɵɵdirectiveInject(RecordActionsAdapter), i0.ɵɵdirectiveInject(RecordViewStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(i1$2.Router)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordHeaderComponent, selectors: [["scrm-record-header"]], hostBindings: function RecordHeaderComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("scroll", function RecordHeaderComponent_scroll_HostBindingHandler() { return ctx.onScroll(); }, false, i0.ɵɵresolveWindow);
        } }, decls: 4, vars: 3, consts: [[1, "record-view-header", 3, "ngClass"], ["class", "row mr-0", 4, "ngIf"], ["class", "row m-0 d-flex justify-content-between ml-1 mr-1", 4, "ngIf"], [1, "row", "mr-0"], [1, "col-md-4", "d-flex", "align-items-center"], [1, "record-view-title", "title-font", 3, "title"], [1, "record-view-name", "pt-3", "pb-3"], [1, "row", "m-0", "d-flex", "justify-content-between", "ml-1", "mr-1"], [1, "col-xs-12", "col-sm-12", "col-md-6", "col-lg-7", "col-xl-8", "record-name-container"], [1, "float-left", "p-0"], ["class", "d-flex record-view-back-button justify-content-start", 4, "ngIf"], [1, "record-view-name-wrapper", "d-flex", "justify-content-md-start", "align-items-center"], [1, "p-0", "d-inline-block", 3, "ngClass"], ["class", "float-right align-items-top d-flex", 4, "ngIf"], ["class", "record-view-name-label d-block p-0 lh-100", 3, "fields", "labelKey", 4, "ngIf"], [1, "col-xs-12", "col-sm-12", "col-md-6", "col-lg-5", "col-xl-4", "align-items-center", "record-view-action-header"], [1, "row", "mr-1", "ml-1", "justify-content-center", "justify-content-md-end"], ["class", "", 4, "ngIf"], [1, "d-flex", "record-view-back-button", "justify-content-start"], [3, "config", 4, "ngIf"], [3, "config"], [1, "float-right", "align-items-top", "d-flex"], [1, "h-100", "lh-100", 3, "record"], [1, "record-view-name-label", "d-block", "p-0", "lh-100", 3, "fields", "labelKey"], [1, ""], ["buttonClass", "settings-button", 3, "config", "actionContext", "klass"]], template: function RecordHeaderComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementContainerStart(0);
            i0.ɵɵelementStart(1, "div", 0);
            i0.ɵɵtemplate(2, RecordHeaderComponent_div_2_Template, 4, 1, "div", 1);
            i0.ɵɵtemplate(3, RecordHeaderComponent_div_3_Template, 11, 11, "div", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementContainerEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngClass", ctx.isScrolled ? "record-view-header-scrolled shadow-md" : "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.loading);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.loading);
        } }, dependencies: [i2.NgClass, i2.NgIf, ModuleTitleComponent, DynamicLabelComponent, ActionGroupMenuComponent, FavoriteToggleComponent, ButtonComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordHeaderComponent, [{
        type: Component,
        args: [{ selector: 'scrm-record-header', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container>\n    <div [ngClass]=\"isScrolled ? 'record-view-header-scrolled shadow-md': ''\" class=\"record-view-header\">\n        <div *ngIf=\"loading\" class=\"row mr-0\">\n            <div class=\"col-md-4 d-flex align-items-center\">\n                <scrm-module-title [title]=\"moduleTitle\" class=\"record-view-title title-font\"></scrm-module-title>\n                <div class=\"record-view-name pt-3 pb-3\"></div>\n            </div>\n        </div>\n        <div *ngIf=\"!loading\" class=\"row m-0 d-flex justify-content-between ml-1 mr-1\">\n            <div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-7 col-xl-8 record-name-container\">\n                <div class=\"float-left p-0\">\n                    <div class=\"d-flex record-view-back-button justify-content-start\" *ngIf=\"mode === 'detail' || mode === 'edit'\">\n                        <scrm-button *ngIf=\"backButtonConfig\" [config]=\"backButtonConfig\"></scrm-button>\n                    </div>\n                </div>\n                <div class=\"record-view-name-wrapper d-flex justify-content-md-start align-items-center\"\n                     [class.justify-content-center]=\"mode === 'detail' || mode === 'edit'\"\n                     [class.justify-content-start]=\"!(mode === 'detail' || mode === 'edit')\"\n                     [class.record-view-name-wrapper-margin-left]=\"mode === 'detail' || mode === 'edit'\"\n                >\n                    <div class=\"p-0 d-inline-block\" [ngClass]=\"isScrolled ? 'record-view-name-scrolled' : 'record-view-name'\">\n                        <div *ngIf=\"record && record.fields && mode !== 'create'\" class=\"float-right align-items-top d-flex\">\n                            <scrm-favorite-toggle [record]=\"record\"\n                                                  class=\"h-100 lh-100\"></scrm-favorite-toggle>\n                        </div>\n                        <scrm-dynamic-label *ngIf=\"record && record.fields\"\n                                            class=\"record-view-name-label d-block p-0 lh-100\"\n                                            [fields]=\"record.fields\"\n                                            [labelKey]=\"getSummaryTemplate()\">\n                        </scrm-dynamic-label>\n\n                    </div>\n                </div>\n            </div>\n            <div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-5 col-xl-4 align-items-center record-view-action-header\">\n                <div class=\"row mr-1 ml-1 justify-content-center justify-content-md-end\">\n                    <div *ngIf=\"record\" class=\"\">\n                        <scrm-action-group-menu\n                                [config]=\"actionsAdapter\"\n                                [actionContext]=\"getActionContext(record)\"\n                                [klass]=\"isScrolled ?  'record-view-actions-scrolled float-right' : 'record-view-actions float-right'\"\n                                buttonClass=\"settings-button\"\n                        >\n                        </scrm-action-group-menu>\n                    </div>\n                </div>\n            </div>\n        </div>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: RecordActionsAdapter }, { type: RecordViewStore }, { type: ModuleNavigation }, { type: AppStateStore }, { type: i1$2.Router }]; }, { onScroll: [{
            type: HostListener,
            args: ['window:scroll']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function CreateRecordComponent_div_0_scrm_status_bar_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-status-bar");
} }
function CreateRecordComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 2);
    i0.ɵɵelement(2, "scrm-record-header");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 3);
    i0.ɵɵelement(4, "hr", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, CreateRecordComponent_div_0_scrm_status_bar_5_Template, 1, 0, "scrm-status-bar", 5);
    i0.ɵɵelement(6, "scrm-record-container");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r0.showStatusBar);
} }
class CreateRecordComponent {
    onEnterKey() {
        if (!this.saveAction || !this.context) {
            return;
        }
        this.actionsAdapter.runAction(this.saveAction, this.context);
    }
    constructor(appState, recordStore, actionsAdapter, route) {
        this.appState = appState;
        this.recordStore = recordStore;
        this.actionsAdapter = actionsAdapter;
        this.route = route;
        this.subs = [];
        this.vm$ = null;
        this.showStatusBar = false;
        this.actionConfig$ = this.recordStore.mode$.pipe(combineLatestWith(this.actionsAdapter.getActions(), this.getViewContext$()), filter(([mode, actions, context]) => mode === 'create'), map(([mode, actions, context]) => ({
            mode,
            actions,
            context
        })));
    }
    ngOnInit() {
        let mode = 'detail';
        const data = (this.route.snapshot && this.route.snapshot.data) || {};
        if (data.mode) {
            mode = data.mode;
        }
        let params = (this.route.snapshot && this.route.snapshot.queryParams) || {};
        params = { ...params };
        let recordId = this.route.snapshot.params.record;
        if (data.duplicate === true) {
            params.originalId = recordId;
            params.isDuplicate = true;
            recordId = '';
        }
        if (data.convert === true) {
            params.originalId = recordId;
            params.isConvert = true;
            recordId = '';
        }
        this.subs.push(this.recordStore.init(this.appState.getModule(), recordId, mode, params).subscribe());
        this.vm$ = this.recordStore.vm$;
        this.appState.removeAllPrevRoutes();
        this.subs.push(this.actionConfig$.subscribe(config => {
            this.context = config.context;
            config.actions.forEach(actionItem => {
                if (actionItem.key === 'saveNew') {
                    this.saveAction = actionItem;
                }
            });
        }));
    }
    getViewContext$() {
        return this.recordStore.viewContext$;
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.recordStore.destroy();
    }
    static { this.ɵfac = function CreateRecordComponent_Factory(t) { return new (t || CreateRecordComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(CreateViewStore), i0.ɵɵdirectiveInject(RecordActionsAdapter), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CreateRecordComponent, selectors: [["scrm-create-record"]], hostBindings: function CreateRecordComponent_HostBindings(rf, ctx) { if (rf & 1) {
            i0.ɵɵlistener("keyup.control.enter", function CreateRecordComponent_keyup_control_enter_HostBindingHandler() { return ctx.onEnterKey(); });
        } }, features: [i0.ɵɵProvidersFeature([
                CreateViewStore,
                RecordActionsAdapter,
                {
                    provide: RecordViewStore,
                    useExisting: CreateViewStore
                },
                RecordViewSidebarWidgetService
            ])], decls: 2, vars: 3, consts: [["class", "record-view", 4, "ngIf"], [1, "record-view"], [1, "record-view-position-sticky"], [1, "record-view-hr-container"], [1, "record-view-hr"], [4, "ngIf"]], template: function CreateRecordComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, CreateRecordComponent_div_0_Template, 7, 1, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, RecordContainerComponent, RecordHeaderComponent, StatusBarComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CreateRecordComponent, [{
        type: Component,
        args: [{ selector: 'scrm-create-record', providers: [
                    CreateViewStore,
                    RecordActionsAdapter,
                    {
                        provide: RecordViewStore,
                        useExisting: CreateViewStore
                    },
                    RecordViewSidebarWidgetService
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<!-- Start Record View Section -->\n<div class=\"record-view\" *ngIf=\"(vm$ | async) as vm\">\n\n    <div class=\"record-view-position-sticky\">\n        <scrm-record-header></scrm-record-header>\n    </div>\n    <div class=\"record-view-hr-container\">\n        <hr class=\"record-view-hr\">\n    </div>\n\n    <scrm-status-bar *ngIf=\"showStatusBar\"></scrm-status-bar>\n    <scrm-record-container></scrm-record-container>\n</div>\n<!-- End Record View Section -->\n" }]
    }], function () { return [{ type: AppStateStore }, { type: CreateViewStore }, { type: RecordActionsAdapter }, { type: i1$2.ActivatedRoute }]; }, { onEnterKey: [{
            type: HostListener,
            args: ['keyup.control.enter']
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordContainerModule {
    static { this.ɵfac = function RecordContainerModule_Factory(t) { return new (t || RecordContainerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordContainerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            WidgetPanelModule,
            AngularSvgIconModule,
            SubpanelContainerModule,
            RecordContentModule,
            TopWidgetModule,
            SidebarWidgetModule,
            RecordContentSkeletonModule,
            RecordPaginationComponent] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordContainerModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordContainerComponent],
                exports: [RecordContainerComponent],
                imports: [
                    CommonModule,
                    WidgetPanelModule,
                    AngularSvgIconModule,
                    SubpanelContainerModule,
                    RecordContentModule,
                    TopWidgetModule,
                    SidebarWidgetModule,
                    RecordContentSkeletonModule,
                    RecordPaginationComponent
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordContainerModule, { declarations: [RecordContainerComponent], imports: [CommonModule,
        WidgetPanelModule,
        AngularSvgIconModule,
        SubpanelContainerModule,
        RecordContentModule,
        TopWidgetModule,
        SidebarWidgetModule,
        RecordContentSkeletonModule,
        RecordPaginationComponent], exports: [RecordContainerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordHeaderModule {
    static { this.ɵfac = function RecordHeaderModule_Factory(t) { return new (t || RecordHeaderModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordHeaderModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModuleTitleModule,
            DynamicLabelModule,
            ActionGroupMenuModule,
            FavoriteToggleModule,
            ButtonModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordHeaderModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordHeaderComponent],
                exports: [RecordHeaderComponent],
                imports: [
                    CommonModule,
                    ModuleTitleModule,
                    DynamicLabelModule,
                    ActionGroupMenuModule,
                    FavoriteToggleModule,
                    ButtonModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordHeaderModule, { declarations: [RecordHeaderComponent], imports: [CommonModule,
        ModuleTitleModule,
        DynamicLabelModule,
        ActionGroupMenuModule,
        FavoriteToggleModule,
        ButtonModule], exports: [RecordHeaderComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewSidebarWidgetService {
    constructor(systemConfigStore, screenSize, store) {
        this.systemConfigStore = systemConfigStore;
        this.screenSize = screenSize;
        this.store = store;
        this.swapSizes = [];
        this.subs = [];
        this.swapSizes = this.systemConfigStore.getUi('widget_swap_screen_sizes');
        this.widgetSwap$ = this.screenSize.screenSize$.pipe(map(screenSize => {
            const swap = isTrue(this.swapSizes[screenSize] ?? false);
            if ((this.widgetSwap === null && swap === true) || (this.widgetSwap !== swap && swap === true)) {
                this.store.showSidebarWidgets = false;
            }
            this.widgetSwap = swap;
            return swap;
        }));
    }
    destroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
    }
    static { this.ɵfac = function ListViewSidebarWidgetService_Factory(t) { return new (t || ListViewSidebarWidgetService)(i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(ScreenSizeObserverService), i0.ɵɵinject(ListViewStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewSidebarWidgetService, factory: ListViewSidebarWidgetService.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewSidebarWidgetService, [{
        type: Injectable
    }], function () { return [{ type: SystemConfigStore }, { type: ScreenSizeObserverService }, { type: ListViewStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class FilterAdapter {
    constructor(store) {
        this.store = store;
    }
    getConfig() {
        return {
            savedFilterEdit: true,
            displayHeader: true,
            module: this.store.getModuleName(),
            filter$: this.store.openFilter$,
            savedFilters$: this.store.filterList.records$,
            searchFields$: this.store.metadata$.pipe(map((meta) => {
                if (!meta || !meta.search) {
                    return {};
                }
                const searchMeta = meta.search;
                let type = 'advanced';
                if (!searchMeta.layout.advanced) {
                    type = 'basic';
                }
                return searchMeta.layout[type];
            })),
            listFields: this.store.metadata.listView.fields,
            onClose: () => {
                this.store.showFilters = false;
            },
            onSearch: () => {
                this.store.showFilters = false;
            },
            updateFilter: (filter, reload = true) => {
                const filters = {};
                filters[filter.key] = filter;
                this.store.setFilters(filters, reload);
            },
            resetFilter: (reload) => {
                this.store.resetFilters(reload);
            },
            addSavedFilter: (filter) => {
                this.store.addSavedFilter(filter);
            },
            removeSavedFilter: (filter) => {
                this.store.removeSavedFilter(filter);
            },
            setOpenFilter: (filter) => {
                this.store.setOpenFilter(filter);
            },
        };
    }
    static { this.ɵfac = function FilterAdapter_Factory(t) { return new (t || FilterAdapter)(i0.ɵɵinject(ListViewStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FilterAdapter, factory: FilterAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilterAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewRecordPanelActionHandler extends RecordPanelActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CancelRecordPanelAction extends ListViewRecordPanelActionHandler {
    constructor() {
        super();
        this.key = 'cancel';
        this.modes = [
            'detail',
            'edit',
            'list',
            'create',
            'massupdate'
        ];
    }
    run(data) {
        data.listStore.closeRecordPanel();
    }
    shouldDisplay() {
        return true;
    }
    static { this.ɵfac = function CancelRecordPanelAction_Factory(t) { return new (t || CancelRecordPanelAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: CancelRecordPanelAction, factory: CancelRecordPanelAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CancelRecordPanelAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RunBulkActionRecordPanelAction extends ListViewRecordPanelActionHandler {
    constructor(message, asyncActionService, confirmation, asyncAction) {
        super();
        this.message = message;
        this.asyncActionService = asyncActionService;
        this.confirmation = confirmation;
        this.asyncAction = asyncAction;
        this.key = 'bulk-action';
        this.modes = [
            'detail',
            'edit',
            'list',
            'create',
            'massupdate'
        ];
    }
    run(data) {
        const definition = data.action;
        const selection = data.listStore.recordList.selection;
        const params = (definition && definition.params) || {};
        if (isFalse(params.allowAll) && selection.all) {
            let message = data.listStore.appStrings.LBL_SELECT_ALL_NOT_ALLOWED;
            this.message.addDangerMessage(message);
            return;
        }
        if (params.min && selection.count < params.min) {
            let message = data.listStore.appStrings.LBL_TOO_FEW_SELECTED;
            message = message.replace('{min}', params.min);
            this.message.addDangerMessage(message);
            return;
        }
        if (params.max && selection.count > params.max) {
            let message = data.listStore.appStrings.LBL_TOO_MANY_SELECTED;
            message = message.replace('{max}', params.max);
            this.message.addDangerMessage(message);
            return;
        }
        this.runBulkAction(data);
    }
    shouldDisplay() {
        return true;
    }
    /**
     * Run async buk action
     *
     * @returns void
     * @param {AsyncActionInput} data: data passed to the async process
     */
    runBulkAction(data) {
        const actionName = `bulk-${data.action.params.bulkAction}`;
        const asyncData = this.buildActionInput(actionName, data);
        this.asyncAction.run(actionName, asyncData).subscribe((process) => {
            this.handleProcessResult(process, data);
        });
    }
    /**
     * Build backend bulk action input
     * @param actionName
     * @param data
     */
    buildActionInput(actionName, data) {
        const displayedFields = [];
        data.listStore.metadata.listView.fields.forEach(value => {
            displayedFields.push(value.name);
        });
        const asyncData = {
            action: actionName,
            module: data.listStore.getModuleName(),
            criteria: null,
            sort: null,
            ids: null,
            fields: displayedFields,
            payload: {
                panelRecord: data.store.recordStore.getBaseStaging()
            }
        };
        const selection = data.listStore.recordList.selection;
        if (selection.all && selection.count > data.listStore.recordList.records.length) {
            asyncData.criteria = data.listStore.recordList.criteria;
            asyncData.sort = data.listStore.recordList.sort;
        }
        if (selection.all && selection.count <= data.listStore.recordList.records.length) {
            asyncData.ids = [];
            data.listStore.recordList.records.forEach(record => {
                data.ids.push(record.id);
            });
        }
        if (!selection.all) {
            asyncData.ids = Object.keys(selection.selected);
        }
        return asyncData;
    }
    /**
     * Run this function once the process is executed
     *
     * @returns void
     * @param {object} process Process data returned by the process once the process is executed
     * @param {object} data ListViewRecordPanelActionData
     */
    handleProcessResult(process, data) {
        if (process.data && process.data.reload) {
            data.listStore.recordList.clearSelection();
            data.listStore.load(false).pipe(take(1)).subscribe();
        }
        if (process.data && process.data.dataUpdated) {
            data.listStore.triggerDataUpdate();
        }
        data.listStore.closeRecordPanel();
    }
    static { this.ɵfac = function RunBulkActionRecordPanelAction_Factory(t) { return new (t || RunBulkActionRecordPanelAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(AsyncActionService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RunBulkActionRecordPanelAction, factory: RunBulkActionRecordPanelAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RunBulkActionRecordPanelAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: AsyncActionService }, { type: ConfirmationModalService }, { type: AsyncActionService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelActionManager extends BaseActionManager {
    constructor(runBulkAction, cancel) {
        super();
        runBulkAction.modes.forEach(mode => this.actions[mode][runBulkAction.key] = runBulkAction);
        cancel.modes.forEach(mode => this.actions[mode][cancel.key] = cancel);
    }
    static { this.ɵfac = function RecordPanelActionManager_Factory(t) { return new (t || RecordPanelActionManager)(i0.ɵɵinject(RunBulkActionRecordPanelAction), i0.ɵɵinject(CancelRecordPanelAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPanelActionManager, factory: RecordPanelActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: RunBulkActionRecordPanelAction }, { type: CancelRecordPanelAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewRecordPanelActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, listStore, language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.listStore = listStore;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
        this.collapseButtons = false;
    }
    getActions(context) {
        return this.store.meta$.pipe(combineLatestWith(this.store.mode$, this.store.stagingRecord$, this.language.vm$), map(([meta, mode, stagingRecord, vm]) => {
            if (!mode || !meta) {
                return [];
            }
            return this.parseModeActions(meta.actions, mode);
        }));
    }
    buildActionData(action, context) {
        return {
            store: this.store,
            listStore: this.listStore,
            action
        };
    }
    getMode() {
        return this.store.getMode();
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, context) {
        this.listStore.load(false).pipe(take(1)).subscribe();
    }
    static { this.ɵfac = function ListViewRecordPanelActionsAdapter_Factory(t) { return new (t || ListViewRecordPanelActionsAdapter)(i0.ɵɵinject(RecordPanelStore), i0.ɵɵinject(ListViewStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordPanelActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewRecordPanelActionsAdapter, factory: ListViewRecordPanelActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewRecordPanelActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: RecordPanelStore }, { type: ListViewStore }, { type: LanguageStore }, { type: RecordPanelActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewRecordPanelActionAdapterFactory {
    constructor(language, actionManager, asyncActionService, message, confirmation, selectModalService, metadata, appMetadataStore) {
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store, listStore) {
        const adapter = new ListViewRecordPanelActionsAdapter(store, listStore, this.language, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.selectModalService, this.metadata, this.appMetadataStore);
        const collapseButtons = listStore?.recordPanelConfig?.collapseActions ?? null;
        if (collapseButtons !== null) {
            adapter.collapseButtons = collapseButtons;
        }
        return adapter;
    }
    static { this.ɵfac = function ListViewRecordPanelActionAdapterFactory_Factory(t) { return new (t || ListViewRecordPanelActionAdapterFactory)(i0.ɵɵinject(LanguageStore), i0.ɵɵinject(RecordPanelActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewRecordPanelActionAdapterFactory, factory: ListViewRecordPanelActionAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewRecordPanelActionAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: LanguageStore }, { type: RecordPanelActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordPanelAdapter {
    constructor(store, recordPanelStoreFactory, actionAdapterFactory, recordManager) {
        this.store = store;
        this.recordPanelStoreFactory = recordPanelStoreFactory;
        this.actionAdapterFactory = actionAdapterFactory;
        this.recordManager = recordManager;
    }
    getConfig() {
        const store = this.createStore();
        return {
            module: this.getModule(),
            title: (this.store.recordPanelConfig && this.store.recordPanelConfig.title) || '',
            store: store,
            meta: this.store.recordPanelConfig,
            actions: this.createActionAdapter(store),
            onClose: () => {
                this.store.closeRecordPanel();
            },
        };
    }
    /**
     * Get configured module
     * @returns {string} module
     */
    getModule() {
        return this.store.recordPanelConfig.module || this.store.getModuleName();
    }
    /**
     * Get configured view mode
     * @returns {string} ViewMode
     */
    getViewMode() {
        return this.store.recordPanelConfig.mode || 'edit';
    }
    /**
     * Create and init store
     * @returns {object} RecordPanelStore
     */
    createStore() {
        const store = this.recordPanelStoreFactory.create();
        const blankRecord = this.recordManager.buildEmptyRecord(this.getModule());
        store.setMetadata(this.store.recordPanelConfig);
        store.initRecord(blankRecord, this.getViewMode(), false);
        return store;
    }
    /**
     * Create action adapter
     * @returns {object} BaseRecordActionsAdapter
     */
    createActionAdapter(store) {
        return this.actionAdapterFactory.create(store, this.store);
    }
    static { this.ɵfac = function RecordPanelAdapter_Factory(t) { return new (t || RecordPanelAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(RecordPanelStoreFactory), i0.ɵɵinject(ListViewRecordPanelActionAdapterFactory), i0.ɵɵinject(RecordManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: RecordPanelAdapter, factory: RecordPanelAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordPanelAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: RecordPanelStoreFactory }, { type: ListViewRecordPanelActionAdapterFactory }, { type: RecordManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ListHeaderComponent_div_7_scrm_button_group_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-button-group", 14);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("config$", ctx_r3.quickFilters.config$)("klass", "quick-filter-button");
} }
function ListHeaderComponent_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9)(1, "div", 10);
    i0.ɵɵelement(2, "scrm-label", 11);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 12);
    i0.ɵɵtemplate(4, ListHeaderComponent_div_7_scrm_button_group_4_Template, 1, 2, "scrm-button-group", 13);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", ctx_r0.quickFilters.config$);
} }
function ListHeaderComponent_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15)(1, "div", 16)(2, "div", 17);
    i0.ɵɵelement(3, "scrm-list-filter", 18);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("config", ctx_r1.filterAdapter.getConfig());
} }
function ListHeaderComponent_div_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15)(1, "div", 16)(2, "div", 17);
    i0.ɵɵelement(3, "scrm-record-panel", 18);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("config", ctx_r2.recordPanelConfig);
} }
class ListHeaderComponent {
    constructor(filterAdapter, listStore, moduleNavigation, recordPanelAdapter, quickFilters) {
        this.filterAdapter = filterAdapter;
        this.listStore = listStore;
        this.moduleNavigation = moduleNavigation;
        this.recordPanelAdapter = recordPanelAdapter;
        this.quickFilters = quickFilters;
        this.actionPanel = '';
        this.showQuickFilters = false;
        this.enableQuickFilters = false;
        this.subs = [];
    }
    get moduleTitle() {
        const module = this.listStore.vm.appData.module;
        const appListStrings = this.listStore.vm.appData.language.appListStrings;
        return this.moduleNavigation.getModuleLabel(module, appListStrings);
    }
    ngOnInit() {
        this.listStore.actionPanel$.subscribe(actionPanel => {
            this.actionPanel = actionPanel;
            if (this.actionPanel === 'recordPanel') {
                this.recordPanelConfig = this.recordPanelAdapter.getConfig();
            }
            else {
                this.recordPanelConfig = null;
            }
        });
        this.subs.push(this.quickFilters.breakdown$.subscribe(breakdown => {
            this.showQuickFilters = isTrue(breakdown);
        }));
        this.subs.push(this.quickFilters.enabled$.subscribe(enabled => {
            this.enableQuickFilters = isTrue(enabled ?? false);
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.recordPanelConfig = null;
    }
    static { this.ɵfac = function ListHeaderComponent_Factory(t) { return new (t || ListHeaderComponent)(i0.ɵɵdirectiveInject(FilterAdapter), i0.ɵɵdirectiveInject(ListViewStore), i0.ɵɵdirectiveInject(ModuleNavigation), i0.ɵɵdirectiveInject(RecordPanelAdapter), i0.ɵɵdirectiveInject(QuickFiltersService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ListHeaderComponent, selectors: [["scrm-list-header"]], features: [i0.ɵɵProvidersFeature([FilterAdapter, RecordPanelAdapter])], decls: 12, vars: 10, consts: [[1, "list-view-header"], [1, "row", "mr-0", "justify-content-md-between"], [1, "custom-col-4", "d-none", "d-md-flex", "align-items-center"], [1, "list-view-title", 3, "title"], [1, "custom-col-8", "d-flex", "align-items-center"], ["class", "d-flex align-items-baseline w-100 justify-content-end pr-3", 4, "ngIf"], [1, "list-view-hr-container"], [1, "list-view-hr"], ["class", "container-fluid pt-2 small-font", 4, "ngIf"], [1, "d-flex", "align-items-baseline", "w-100", "justify-content-end", "pr-3"], [1, "text-nowrap", "text-muted", "fs-70", "pl-1", "mr-1"], ["labelKey", "LBL_QUICK_FILTERS"], [1, "pr-xxl-1", "mr-xxl-1"], [3, "config$", "klass", 4, "ngIf"], [3, "config$", "klass"], [1, "container-fluid", "pt-2", "small-font"], [1, "row"], [1, "col"], [3, "config"]], template: function ListHeaderComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementContainerStart(0);
            i0.ɵɵelementStart(1, "div", 0)(2, "div", 1)(3, "div", 2);
            i0.ɵɵelement(4, "scrm-module-title", 3);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "div", 4);
            i0.ɵɵelement(6, "scrm-settings-menu");
            i0.ɵɵelementEnd()();
            i0.ɵɵtemplate(7, ListHeaderComponent_div_7_Template, 5, 1, "div", 5);
            i0.ɵɵelementStart(8, "div", 6);
            i0.ɵɵelement(9, "hr", 7);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(10, ListHeaderComponent_div_10_Template, 4, 1, "div", 8);
            i0.ɵɵtemplate(11, ListHeaderComponent_div_11_Template, 4, 1, "div", 8);
            i0.ɵɵelementEnd();
            i0.ɵɵelementContainerEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵclassProp("justify-content-center", !(ctx.showQuickFilters && ctx.enableQuickFilters))("justify-content-end", ctx.showQuickFilters && ctx.enableQuickFilters);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("title", ctx.moduleTitle);
            i0.ɵɵadvance(1);
            i0.ɵɵclassProp("pr-3", ctx.showQuickFilters && ctx.enableQuickFilters);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.showQuickFilters && ctx.enableQuickFilters);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.actionPanel === "filters");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.actionPanel === "recordPanel" && ctx.recordPanelConfig);
        } }, dependencies: [i2.NgIf, ModuleTitleComponent, SettingsMenuComponent, ListFilterComponent, RecordPanelComponent, ButtonGroupComponent, LabelComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListHeaderComponent, [{
        type: Component,
        args: [{ selector: 'scrm-list-header', providers: [FilterAdapter, RecordPanelAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container>\n    <div class=\"list-view-header\">\n        <div class=\"row mr-0 justify-content-md-between\"\n             [class.justify-content-center]=\"!(showQuickFilters && enableQuickFilters)\"\n             [class.justify-content-end]=\"(showQuickFilters && enableQuickFilters)\">\n            <div class=\"custom-col-4 d-none d-md-flex align-items-center\">\n                <scrm-module-title class=\"list-view-title\" [title]=\"moduleTitle\"></scrm-module-title>\n            </div>\n            <div class=\"custom-col-8 d-flex align-items-center\"\n                 [class.pr-3]=\"(showQuickFilters && enableQuickFilters)\"\n            >\n                <scrm-settings-menu></scrm-settings-menu>\n            </div>\n        </div>\n\n        <div *ngIf=\"showQuickFilters && enableQuickFilters\"\n             class=\"d-flex align-items-baseline w-100 justify-content-end pr-3\">\n            <div class=\"text-nowrap text-muted fs-70 pl-1 mr-1\">\n                <scrm-label labelKey=\"LBL_QUICK_FILTERS\"></scrm-label>\n            </div>\n            <div class=\"pr-xxl-1 mr-xxl-1\">\n                <scrm-button-group *ngIf=\"quickFilters.config$\" [config$]=\"quickFilters.config$\" [klass]=\"'quick-filter-button'\"></scrm-button-group>\n            </div>\n        </div>\n\n        <div class=\"list-view-hr-container\">\n            <hr class=\"list-view-hr\">\n        </div>\n        <div *ngIf=\"actionPanel === 'filters'\" class=\"container-fluid pt-2 small-font\">\n            <div class=\"row\">\n                <div class=\"col\">\n                    <scrm-list-filter [config]=\"filterAdapter.getConfig()\"></scrm-list-filter>\n                </div>\n            </div>\n        </div>\n        <div *ngIf=\"actionPanel === 'recordPanel' && recordPanelConfig\" class=\"container-fluid pt-2 small-font\">\n            <div class=\"row\">\n                <div class=\"col\">\n                    <scrm-record-panel [config]=\"recordPanelConfig\"></scrm-record-panel>\n                </div>\n            </div>\n        </div>\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: FilterAdapter }, { type: ListViewStore }, { type: ModuleNavigation }, { type: RecordPanelAdapter }, { type: QuickFiltersService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LineActionsAdapter extends BaseLineActionsAdapter {
    constructor(store, actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    getActions(context = null) {
        return this.store.lineActions$.pipe(combineLatestWith(of('list').pipe(shareReplay())), map(([lineActions, mode]) => {
            return this.parseModeActions(lineActions, mode, context);
        }));
    }
    getModuleName(record) {
        return this.store.getModuleName();
    }
    reload(action, process, record) {
        this.store.recordList.clearSelection();
        this.store.recordList.resetPagination();
    }
    getMode() {
        return 'list';
    }
    static { this.ɵfac = function LineActionsAdapter_Factory(t) { return new (t || LineActionsAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(LineActionActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LineActionsAdapter, factory: LineActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LineActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: LineActionActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BulkActionsAdapter {
    constructor(store, message, confirmation, selectModalService, asyncAction, metadata, appMetadataStore) {
        this.store = store;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.asyncAction = asyncAction;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    /**
     * Get bulk action
     * @returns {object} Observable<BulkActionsMap>
     */
    getBulkActions() {
        return this.store.metadata$.pipe(map((metadata) => metadata.listView.bulkActions));
    }
    /**
     * Execute bulk actions
     * @param {string} action
     */
    executeBulkAction(action) {
        const selection = this.store.recordList.selection;
        const definition = this.store.metadata.listView.bulkActions[action];
        const actionName = `bulk-${action}`;
        this.message.removeMessages();
        if (isFalse(definition.params.allowAll) && selection.all) {
            let message = this.store.appStrings.LBL_SELECT_ALL_NOT_ALLOWED;
            this.message.addDangerMessage(message);
            return;
        }
        if (definition.params.min && selection.count < definition.params.min) {
            let message = this.store.appStrings.LBL_TOO_FEW_SELECTED;
            message = message.replace('{min}', definition.params.min);
            this.message.addDangerMessage(message);
            return;
        }
        if (definition.params.max && selection.count > definition.params.max) {
            let message = this.store.appStrings.LBL_TOO_MANY_SELECTED;
            message = message.replace('{max}', definition.params.max);
            this.message.addDangerMessage(message);
            return;
        }
        const displayedFields = [];
        this.store.metadata.listView.fields.forEach(value => {
            displayedFields.push(value.name);
        });
        const data = {
            action: actionName,
            module: this.store.getModuleName(),
            criteria: null,
            sort: null,
            ids: null,
            fields: displayedFields
        };
        if (selection.all && selection.count > this.store.recordList.records.length) {
            data.criteria = this.store.recordList.criteria;
            data.sort = this.store.recordList.sort;
        }
        if (selection.all && selection.count <= this.store.recordList.records.length) {
            data.ids = [];
            this.store.recordList.records.forEach(record => {
                data.ids.push(record.id);
            });
        }
        if (!selection.all) {
            data.ids = Object.keys(selection.selected);
        }
        const params = (definition && definition.params) || {};
        const displayConfirmation = params.displayConfirmation || false;
        const confirmationLabel = params.confirmationLabel || '';
        const selectModal = definition.params && definition.params.selectModal;
        const selectModule = selectModal && selectModal.module;
        const recordPanel = definition.params && definition.params.recordPanel;
        if (recordPanel) {
            this.store.openRecordPanel(recordPanel);
            return;
        }
        if (displayConfirmation) {
            this.confirmation.showModal(confirmationLabel, () => {
                if (!selectModule) {
                    this.runBulkAction(actionName, data);
                    return;
                }
                this.showSelectModal(selectModal.module, actionName, data);
            });
            return;
        }
        if (!selectModule) {
            this.runBulkAction(actionName, data);
            return;
        }
        this.showSelectModal(selectModal.module, actionName, data);
    }
    /**
     * Run async buk action
     *
     * @returns void
     * @param {string} selectModule: module for which records are listed in Select Modal/Popup
     * @param {string} asyncAction: bulk action name
     * @param {AsyncActionInput} asyncData: data passed to the async process
     */
    showSelectModal(selectModule, asyncAction, asyncData) {
        this.selectModalService.showSelectModal(selectModule, (modalRecord) => {
            if (modalRecord) {
                const { fields, formGroup, ...baseRecord } = modalRecord;
                asyncData.modalRecord = baseRecord;
            }
            this.runBulkAction(asyncAction, asyncData);
        });
    }
    /**
     * Run async buk action
     *
     * @returns void
     * @param {string} asyncAction: bulk action name
     * @param {AsyncActionInput} asyncData: data passed to the async process
     */
    runBulkAction(asyncAction, asyncData) {
        this.asyncAction.run(asyncAction, asyncData).subscribe((process) => {
            this.handleProcessResult(process);
        });
    }
    /**
     * Run this function once the process is executed
     *
     * @returns void
     * @param {Process} process: data returned by the process once the process is executed
     */
    handleProcessResult(process) {
        if (process?.data && process?.data?.reload) {
            this.store.recordList.clearSelection();
            this.store.load(false).pipe(take(1)).subscribe();
        }
        if (process?.data && process?.data?.dataUpdated) {
            this.store.triggerDataUpdate();
        }
        this.reloadMetadata(this.store.getModuleName(), process);
    }
    /**
     * Reload the metadata for the module
     * @param moduleName
     * @param process
     * @protected
     */
    reloadMetadata(moduleName, process) {
        const typesToLoad = [];
        if (this.shouldReloadRecentlyViewed(process)) {
            typesToLoad.push(this.metadata.typeKeys.recentlyViewed);
        }
        if (this.shouldReloadFavorites(process)) {
            typesToLoad.push(this.metadata.typeKeys.favorites);
        }
        if (typesToLoad && typesToLoad.length) {
            this.metadata.reloadModuleMetadata(moduleName, typesToLoad, false).pipe(take(1)).subscribe();
        }
        if (this.shouldReloadGlobalRecentlyViewed(process)) {
            this.appMetadataStore.load(moduleName, ['globalRecentlyViewed'], false).pipe(take(1)).subscribe();
        }
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReloadGlobalRecentlyViewed(process) {
        return !!(process?.data && process?.data?.reloadGlobalRecentlyViewed);
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReloadRecentlyViewed(process) {
        return !!(process?.data && process?.data?.reloadRecentlyViewed);
    }
    /**
     * Should reload page
     * @param process
     */
    shouldReloadFavorites(process) {
        return !!(process?.data && process.data?.reloadFavorites);
    }
    static { this.ɵfac = function BulkActionsAdapter_Factory(t) { return new (t || BulkActionsAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BulkActionsAdapter, factory: BulkActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BulkActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: AsyncActionService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class BulkActionsAdapterFactory {
    constructor(message, confirmation, selectModalService, asyncAction, metadata, appMetadataStore) {
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.asyncAction = asyncAction;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store) {
        return new BulkActionsAdapter(store, this.message, this.confirmation, this.selectModalService, this.asyncAction, this.metadata, this.appMetadataStore);
    }
    static { this.ɵfac = function BulkActionsAdapterFactory_Factory(t) { return new (t || BulkActionsAdapterFactory)(i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BulkActionsAdapterFactory, factory: BulkActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BulkActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: AsyncActionService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableActionHandler extends ActionHandler {
    /**
     * Navigate back
     * @param navigation
     * @param params
     * @param id
     * @param moduleName
     * @param record
     */
    navigateBack(navigation, params, id, moduleName, record) {
        let returnModule = navigation.getReturnModule(params);
        let returnAction = navigation.getReturnAction(params);
        let returnId = navigation.getReturnId(params);
        if (id === returnId) {
            return;
        }
        if (returnModule === moduleName &&
            returnAction === 'record' &&
            returnId !== id) {
            return;
        }
        if (!returnModule || !returnAction) {
            return;
        }
        navigation.navigateBack(record, moduleName, params);
    }
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class AsyncProcessTableAction extends TableActionHandler {
    constructor() {
        super();
        this.key = 'async-process';
        this.modes = ALL_VIEW_MODES;
    }
    run(data) {
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function AsyncProcessTableAction_Factory(t) { return new (t || AsyncProcessTableAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AsyncProcessTableAction, factory: AsyncProcessTableAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AsyncProcessTableAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class SelectColumnsTableAction extends TableActionHandler {
    constructor() {
        super();
        this.key = 'select-columns';
        this.modes = ['list'];
    }
    run(data) {
        data.store.openColumnChooserDialog();
    }
    shouldDisplay(data) {
        return true;
    }
    static { this.ɵfac = function SelectColumnsTableAction_Factory(t) { return new (t || SelectColumnsTableAction)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SelectColumnsTableAction, factory: SelectColumnsTableAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SelectColumnsTableAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return []; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableActionManager extends BaseActionManager {
    constructor(async, selectColumns) {
        super();
        this.async = async;
        this.selectColumns = selectColumns;
        selectColumns.modes.forEach(mode => this.actions[mode][selectColumns.key] = selectColumns);
        async.modes.forEach(mode => this.actions[mode][async.key] = async);
    }
    static { this.ɵfac = function TableActionManager_Factory(t) { return new (t || TableActionManager)(i0.ɵɵinject(AsyncProcessTableAction), i0.ɵɵinject(SelectColumnsTableAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TableActionManager, factory: TableActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: AsyncProcessTableAction }, { type: SelectColumnsTableAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewTableActionsAdapter extends BaseActionsAdapter {
    constructor(store, actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    buildActionData(action, context) {
        return {
            store: this.store,
            action: action
        };
    }
    /**
     * Get action name
     * @param action
     */
    getActionName(action) {
        return `table-action-${action.key}`;
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const selection = this.store.recordList.selection;
        const displayedFields = [];
        this.store.metadata.listView.fields.forEach(value => {
            displayedFields.push(value.name);
        });
        const data = {
            action: actionName,
            module: moduleName,
            criteria: null,
            sort: null,
            ids: null,
            fields: displayedFields,
            params: (action && action.params) || [],
        };
        if (selection.all && selection.count > this.store.recordList.records.length) {
            data.criteria = this.store.recordList.criteria;
            data.sort = this.store.recordList.sort;
        }
        if (selection.all && selection.count <= this.store.recordList.records.length) {
            data.ids = [];
            this.store.recordList.records.forEach(record => {
                data.ids.push(record.id);
            });
        }
        if (!selection.all) {
            data.ids = Object.keys(selection.selected);
        }
        return data;
    }
    getActions(context = null) {
        return this.store.tableActions$.pipe(combineLatestWith(of('list').pipe(shareReplay())), map(([tableActions, mode]) => {
            return this.parseModeActions(tableActions, mode, context);
        }));
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, record) {
        this.store.recordList.clearSelection();
        this.store.recordList.resetPagination();
    }
    getMode() {
        return 'list';
    }
    static { this.ɵfac = function ListViewTableActionsAdapter_Factory(t) { return new (t || ListViewTableActionsAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(TableActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewTableActionsAdapter, factory: ListViewTableActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewTableActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: TableActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2023 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListviewTableActionsAdapterFactory {
    constructor(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore) {
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.selectModalService = selectModalService;
        this.metadata = metadata;
        this.appMetadataStore = appMetadataStore;
    }
    create(store) {
        return new ListViewTableActionsAdapter(store, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.language, this.selectModalService, this.metadata, this.appMetadataStore);
    }
    static { this.ɵfac = function ListviewTableActionsAdapterFactory_Factory(t) { return new (t || ListviewTableActionsAdapterFactory)(i0.ɵɵinject(TableActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListviewTableActionsAdapterFactory, factory: ListviewTableActionsAdapterFactory.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListviewTableActionsAdapterFactory, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: TableActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: SelectModalService }, { type: MetadataStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class TableAdapter {
    constructor(store, metadata, actionManager, asyncActionService, message, confirmation, language, bulkActionsAdapterFactory, listviewTableActionsAdapterFactory, selectModalService, preferences, systemConfigs, appMetadataStore) {
        this.store = store;
        this.metadata = metadata;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.language = language;
        this.bulkActionsAdapterFactory = bulkActionsAdapterFactory;
        this.listviewTableActionsAdapterFactory = listviewTableActionsAdapterFactory;
        this.selectModalService = selectModalService;
        this.preferences = preferences;
        this.systemConfigs = systemConfigs;
        this.appMetadataStore = appMetadataStore;
    }
    getTable() {
        return {
            showHeader: true,
            showFooter: true,
            module: this.store.getModuleName(),
            columns: this.store.columns$,
            lineActions: this.getLineActionsDataSource(),
            selection$: this.store.selection$,
            sort$: this.store.sort$,
            maxColumns$: of(4),
            loading$: this.store.recordList.loading$,
            dataSource: this.store.recordList,
            selection: this.store.recordList,
            bulkActions: this.getBulkActionsDataSource(this.store),
            tableActions: this.getTableActions(this.store),
            pagination: this.store.recordList,
            paginationType: this.preferences.getUserPreference('listview_pagination_type') ?? this.systemConfigs.getConfigValue('listview_pagination_type'),
            maxListHeight: this.preferences.getUserPreference('listview_max_height') ?? this.systemConfigs.getConfigValue('listview_max_height'),
            toggleRecordSelection: (id) => {
                this.store.recordList.toggleSelection(id);
            },
            updateSorting: (orderBy, sortOrder) => {
                this.store.recordList.updateSorting(orderBy, sortOrder);
                this.store.updateSortLocalStorage();
            },
            loadMore: () => {
                const jump = this.preferences.getUserPreference('list_max_entries_per_page') ?? this.systemConfigs.getConfigValue('list_max_entries_per_page');
                const pagination = this.store.recordList.getPagination();
                const currentPageSize = pagination.pageSize || 0;
                const newPageSize = Number(currentPageSize) + Number(jump);
                this.store.recordList.setPageSize(newPageSize);
                this.store.recordList.updatePagination(pagination.current);
            },
            allLoaded: () => {
                const pagination = this.store.recordList.getPagination();
                if (!pagination) {
                    return false;
                }
                if (Number(pagination.pageLast) >= Number(pagination.total)) {
                    return true;
                }
                return Number(pagination.pageSize) >= Number(pagination.total);
            }
        };
    }
    getLineActionsDataSource() {
        return new LineActionsAdapter(this.store, this.actionManager, this.asyncActionService, this.message, this.confirmation, this.language, this.selectModalService, this.metadata, this.appMetadataStore);
    }
    getBulkActionsDataSource(store) {
        return this.bulkActionsAdapterFactory.create(store);
    }
    getTableActions(store) {
        return this.listviewTableActionsAdapterFactory.create(store);
    }
    static { this.ɵfac = function TableAdapter_Factory(t) { return new (t || TableAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LineActionActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(BulkActionsAdapterFactory), i0.ɵɵinject(ListviewTableActionsAdapterFactory), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(UserPreferenceStore), i0.ɵɵinject(SystemConfigStore), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TableAdapter, factory: TableAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: MetadataStore }, { type: LineActionActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: LanguageStore }, { type: BulkActionsAdapterFactory }, { type: ListviewTableActionsAdapterFactory }, { type: SelectModalService }, { type: UserPreferenceStore }, { type: SystemConfigStore }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListViewSidebarWidgetAdapter {
    constructor(store, metadata) {
        this.store = store;
        this.metadata = metadata;
        this.config$ = this.metadata.listMetadata$.pipe(combineLatestWith(this.store.showSidebarWidgets$, this.store.widgets$), map(([metadata, show, widgetsEnabled]) => {
            if (metadata.sidebarWidgets && metadata.sidebarWidgets.length) {
                metadata.sidebarWidgets.forEach(widget => {
                    if (widget && widget.refreshOn === 'data-update') {
                        widget.reload$ = this.store.dataSetUpdate$.pipe(map(() => true));
                    }
                    else if (widget && widget.refreshOn === 'data-reload') {
                        widget.reload$ = this.store.records$.pipe(map(() => true));
                    }
                });
            }
            return {
                widgets: metadata.sidebarWidgets || [],
                show,
                widgetsEnabled,
            };
        }));
    }
    static { this.ɵfac = function ListViewSidebarWidgetAdapter_Factory(t) { return new (t || ListViewSidebarWidgetAdapter)(i0.ɵɵinject(ListViewStore), i0.ɵɵinject(MetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ListViewSidebarWidgetAdapter, factory: ListViewSidebarWidgetAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListViewSidebarWidgetAdapter, [{
        type: Injectable
    }], function () { return [{ type: ListViewStore }, { type: MetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0$1 = function (a0) { return { "col-lg-12": a0 }; };
function ListContainerComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵelement(2, "scrm-table", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(2, _c0$1, !ctx_r0.displayWidgets));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r0.tableConfig);
} }
function ListContainerComponent_ng_container_3_ng_container_1_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵelement(1, "scrm-sidebar-widget", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const widget_r4 = ctx.$implicit;
    const ctx_r3 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", widget_r4)("context", ctx_r3.getViewContext())("context$", ctx_r3.store.context$)("type", widget_r4.type);
} }
function ListContainerComponent_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 5);
    i0.ɵɵtemplate(2, ListContainerComponent_ng_container_3_ng_container_1_div_2_Template, 2, 4, "div", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵstyleProp("display", ctx_r2.widgetDisplayType);
    i0.ɵɵclassProp("mt-0", ctx_r2.swapWidgets);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2.sidebarWidgetConfig.widgets);
} }
function ListContainerComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ListContainerComponent_ng_container_3_ng_container_1_Template, 3, 5, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r1.swapWidgets || ctx_r1.swapWidgets && ctx_r1.displayWidgets);
} }
class ListContainerComponent {
    constructor(store, adapter, maxColumnCalculator, languageStore, sidebarWidgetAdapter, systemConfigs, sidebarWidgetHandler) {
        this.store = store;
        this.adapter = adapter;
        this.maxColumnCalculator = maxColumnCalculator;
        this.languageStore = languageStore;
        this.sidebarWidgetAdapter = sidebarWidgetAdapter;
        this.systemConfigs = systemConfigs;
        this.sidebarWidgetHandler = sidebarWidgetHandler;
        this.screen = ScreenSize.Medium;
        this.maxColumns = 5;
        this.displayWidgets = true;
        this.swapWidgets = false;
        this.widgetDisplayType = 'none';
        this.subs = [];
    }
    ngOnInit() {
        this.tableConfig = this.adapter.getTable();
        this.tableConfig.maxColumns$ = this.getMaxColumns();
        if (this.store?.metadata?.listView?.maxHeight) {
            this.tableConfig.maxListHeight = this.store.metadata.listView.maxHeight;
        }
        if (!this.tableConfig?.maxListHeight) {
            const ui = this.systemConfigs.getConfigValue('ui');
            this.tableConfig.maxListHeight = ui.listview_max_height;
        }
        this.tableConfig.paginationType = this?.store?.metadata?.listView?.paginationType ?? this.tableConfig.paginationType;
        this.subs.push(this.sidebarWidgetAdapter.config$.subscribe(sidebarWidgetConfig => {
            this.sidebarWidgetConfig = sidebarWidgetConfig;
            this.displayWidgets = this.store.widgets && this.store.showSidebarWidgets;
            this.widgetDisplayType = this.getDisplay(!!(this.sidebarWidgetConfig.show && this.sidebarWidgetConfig.widgets));
        }));
        this.subs.push(this.sidebarWidgetHandler.widgetSwap$.subscribe(swap => {
            this.swapWidgets = swap;
        }));
    }
    ngOnDestroy() {
        this.subs.forEach(sub => sub.unsubscribe());
        this.subs = [];
    }
    getMaxColumns() {
        return this.maxColumnCalculator.getMaxColumns(this.store.widgets$);
    }
    getDisplayWidgets() {
        return this.store.widgets && this.store.showSidebarWidgets;
    }
    getDisplay(display) {
        let displayType = 'none';
        if (display) {
            displayType = 'block';
        }
        return displayType;
    }
    getViewContext() {
        return this.store.getViewContext();
    }
    static { this.ɵfac = function ListContainerComponent_Factory(t) { return new (t || ListContainerComponent)(i0.ɵɵdirectiveInject(ListViewStore), i0.ɵɵdirectiveInject(TableAdapter), i0.ɵɵdirectiveInject(MaxColumnsCalculator), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(ListViewSidebarWidgetAdapter), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(ListViewSidebarWidgetService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ListContainerComponent, selectors: [["scrm-list-container"]], features: [i0.ɵɵProvidersFeature([TableAdapter, MaxColumnsCalculator, ListViewSidebarWidgetAdapter])], decls: 4, vars: 2, consts: [[1, "list-view-container", "container-fluid", "pt-2"], [1, "row"], [4, "ngIf"], [1, "col-lg-9", 3, "ngClass"], [3, "config"], [1, "col-lg-3", "list-widget-container", "pl-0"], ["class", "mb-3", 4, "ngFor", "ngForOf"], [1, "mb-3"], [3, "config", "context", "context$", "type"]], template: function ListContainerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1);
            i0.ɵɵtemplate(2, ListContainerComponent_ng_container_2_Template, 3, 4, "ng-container", 2);
            i0.ɵɵtemplate(3, ListContainerComponent_ng_container_3_Template, 2, 1, "ng-container", 2);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", !ctx.swapWidgets || ctx.swapWidgets && !ctx.displayWidgets);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.sidebarWidgetConfig.widgetsEnabled);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, TableComponent, SidebarWidgetComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListContainerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-list-container', providers: [TableAdapter, MaxColumnsCalculator, ListViewSidebarWidgetAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start List View Container Section -->\n\n<div class=\"list-view-container container-fluid pt-2\">\n    <div class=\"row\">\n        <ng-container *ngIf=\"!swapWidgets || (swapWidgets && !displayWidgets)\">\n            <div [ngClass]=\"{ 'col-lg-12': !displayWidgets }\"\n                 class=\"col-lg-9\"\n            >\n                <scrm-table [config]=\"tableConfig\"></scrm-table>\n            </div>\n        </ng-container>\n\n\n        <ng-container *ngIf=\"sidebarWidgetConfig.widgetsEnabled\">\n            <ng-container *ngIf=\"!swapWidgets || (swapWidgets && displayWidgets)\">\n            <div [style.display]=\"widgetDisplayType\"\n                 [class.mt-0]=\"swapWidgets\"\n                 class=\"col-lg-3 list-widget-container pl-0\">\n                <div *ngFor=\"let widget of sidebarWidgetConfig.widgets\" class=\"mb-3\">\n                    <scrm-sidebar-widget [config]=\"widget\"\n                                         [context]=\"getViewContext()\"\n                                         [context$]=\"store.context$\"\n                                         [type]=\"widget.type\">\n                    </scrm-sidebar-widget>\n                </div>\n            </div>\n            </ng-container>\n        </ng-container>\n\n\n    </div>\n</div>\n\n<!-- End List View Container Section -->\n" }]
    }], function () { return [{ type: ListViewStore }, { type: TableAdapter }, { type: MaxColumnsCalculator }, { type: LanguageStore }, { type: ListViewSidebarWidgetAdapter }, { type: SystemConfigStore }, { type: ListViewSidebarWidgetService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function ListComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelement(1, "scrm-list-header")(2, "scrm-list-container");
    i0.ɵɵelementEnd();
} }
class ColorService {
    constructor() {
        this.colors = null;
        this.loading = null;
    }
    getColors() {
        if (this.colors)
            return Promise.resolve(this.colors);
        if (this.loading)
            return this.loading;
        const basePath = window.location.pathname.split("/legacy")[0]; // gets "/johncrm"
        this.loading = fetch(`${basePath}/legacy/custom/field_colors.php`)
            .then(res => res.json())
            .then(data => {
            this.colors = data;
            return data;
        })
            .catch(error => {
            console.error("Failed to load color mappings:", error);
            return { tagColors: {}, callStatus: {} };
        });
        return this.loading;
    }
    static { this.ɵfac = function ColorService_Factory(t) { return new (t || ColorService)(); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ColorService, factory: ColorService.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ColorService, [{
        type: Injectable,
        args: [{ providedIn: 'root' }]
    }], null, null); })();
class ListComponent {
    constructor(appState, listStore, quickFilters, sidebarWidgetHandler, recordPaginationService, colorService) {
        this.appState = appState;
        this.listStore = listStore;
        this.quickFilters = quickFilters;
        this.sidebarWidgetHandler = sidebarWidgetHandler;
        this.recordPaginationService = recordPaginationService;
        this.colorService = colorService;
        this.destroy$ = new Subject();
        this.TAG_COLORS_LIST = {};
        this.CALL_STATUS_STYLES = {};
        this.vm$ = null;
    }
    ngOnInit() {
        console.log("List component init");
        this.appState.removeAllPrevRoutes();
        this.module = this.appState.getModule();
        this.listSub = this.listStore.init(this.module).subscribe();
        this.vm$ = this.listStore.vm$;
        this.vm$.pipe(takeUntil(this.destroy$)).subscribe(() => {
            // Wait for DOM to render - using a one-time timeout instead of repeatedly polling
            setTimeout(() => {
                this.setupDomObserver();
            }, 300);
        });
    }
    ngAfterViewInit() {
        console.log("list.component.ts ngAfterViewInit");
        // Load colors once and cache them
        this.loadColors().then(() => {
            // Apply styles once after colors are loaded
            this.injectListTagColors();
            this.injectCallStatusDotList();
        });
    }
    ngOnDestroy() {
        if (this.listSub) {
            this.listSub.unsubscribe();
        }
        // Clean up the observer if it exists
        if (this.domObserver) {
            this.domObserver.disconnect();
        }
        // Signal all subscriptions to complete
        this.destroy$.next();
        this.destroy$.complete();
        this.updateListLocalStorage();
        this.quickFilters.destroy();
        this.sidebarWidgetHandler.destroy();
        this.listStore.destroy();
    }
    setupDomObserver() {
        // Clean up any existing observer
        if (this.domObserver) {
            this.domObserver.disconnect();
        }
        const listTable = document.querySelector(".list-view-table") || document.body;
        this.domObserver = new MutationObserver(() => {
            console.log("[MutationObserver] Detected DOM changes in ListView");
            this.injectListTagColors();
            this.injectCallStatusDotList();
        });
        this.domObserver.observe(listTable, { childList: true, subtree: true });
    }
    updateListLocalStorage() {
        this.recordPaginationService.updateRecordListLocalStorage(this.listStore.recordList.records, this.listStore.recordList.pagination);
    }
    injectCallStatusDotList() {
        console.log("[CallStatus][ListView] Injecting call status dots");
        const callStatusEls = document.querySelectorAll(".field-name-call_status_c scrm-dropdownenum-detail");
        if (callStatusEls.length === 0) {
            console.log("[CallStatus][ListView] No elements found yet");
            return;
        }
        console.log(`[CallStatus][ListView] Found ${callStatusEls.length} elements.`);
        callStatusEls.forEach((el, index) => {
            const rawText = el.textContent?.trim() || "";
            const cleanVal = rawText.toLowerCase().replace(/\s+/g, "");
            const styleInfo = this.CALL_STATUS_STYLES[cleanVal];
            if (styleInfo) {
                const spanExists = el.querySelector(".call-status-pill");
                if (!spanExists) {
                    console.log(`[CallStatus][ListView][${index}] Applying color: ${styleInfo.color}`);
                    el.innerHTML = `<span class="call-status-pill">${styleInfo.emoji} ${rawText}</span>`;
                    const span = el.querySelector(".call-status-pill");
                    if (span) {
                        span.style.backgroundColor = styleInfo.color;
                        span.style.color = "#fff";
                        span.style.padding = "2px 10px";
                        span.style.borderRadius = "20px";
                        span.style.fontWeight = "600";
                        span.style.display = "inline-block";
                        span.style.textTransform = "uppercase";
                        span.style.fontSize = "12px";
                        span.style.letterSpacing = "0.5px";
                    }
                }
            }
        });
    }
    injectListTagColors() {
        const tagLists = document.querySelectorAll(".field-name-tag_c scrm-multienum-detail li");
        if (tagLists.length === 0) {
            return;
        }
        tagLists.forEach((el) => {
            const label = el.textContent?.trim().toLowerCase();
            this.applyFlatTagStyleList(el, label);
        });
    }
    async loadColors() {
        try {
            const data = await this.colorService.getColors();
            this.TAG_COLORS_LIST = data.tagColors;
            this.CALL_STATUS_STYLES = data.callStatus;
        }
        catch (error) {
            console.error("Failed to load color mappings:", error);
        }
    }
    applyFlatTagStyleList(el, label) {
        const color = this.TAG_COLORS_LIST[label.toLowerCase()];
        if (!color)
            return;
        el.style.backgroundColor = color;
        el.style.color = "white";
        el.style.fontSize = "12px";
        el.style.fontWeight = "bold";
        el.style.padding = "2px 8px";
        el.style.borderRadius = "12px";
        el.style.display = "inline-block";
        el.style.margin = "2px";
    }
    static { this.ɵfac = function ListComponent_Factory(t) { return new (t || ListComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(ListViewStore), i0.ɵɵdirectiveInject(QuickFiltersService), i0.ɵɵdirectiveInject(ListViewSidebarWidgetService), i0.ɵɵdirectiveInject(RecordPaginationService), i0.ɵɵdirectiveInject(ColorService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ListComponent, selectors: [["scrm-list"]], features: [i0.ɵɵProvidersFeature([ListViewStore, QuickFiltersService, ListViewSidebarWidgetService])], decls: 2, vars: 3, consts: [["class", "list-view", 4, "ngIf"], [1, "list-view"]], template: function ListComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, ListComponent_div_0_Template, 3, 0, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, ListHeaderComponent, ListContainerComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListComponent, [{
        type: Component,
        args: [{ selector: "scrm-list", providers: [ListViewStore, QuickFiltersService, ListViewSidebarWidgetService], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start List View Section -->\n<div class=\"list-view\" *ngIf=\"(vm$ | async) as vm\">\n    <scrm-list-header></scrm-list-header>\n    <scrm-list-container></scrm-list-container>\n</div>\n<!-- End List View Section -->\n" }]
    }], function () { return [{ type: AppStateStore }, { type: ListViewStore }, { type: QuickFiltersService }, { type: ListViewSidebarWidgetService }, { type: RecordPaginationService }, { type: ColorService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const _c0 = ["recordContainer"];
function RecordComponent_div_0_scrm_status_bar_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "scrm-status-bar");
} }
function RecordComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 2);
    i0.ɵɵelement(2, "scrm-record-header");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 3);
    i0.ɵɵelement(4, "hr", 4);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, RecordComponent_div_0_scrm_status_bar_5_Template, 1, 0, "scrm-status-bar", 5);
    i0.ɵɵelement(6, "scrm-record-container");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r0.showStatusBar);
} }
class RecordComponent {
    constructor(appState, recordStore, route, sidebarWidgetHandler, colorService) {
        this.appState = appState;
        this.recordStore = recordStore;
        this.route = route;
        this.sidebarWidgetHandler = sidebarWidgetHandler;
        this.colorService = colorService;
        this.vm$ = null;
        this.showStatusBar = false;
        this.destroy$ = new Subject();
        this.TAG_COLORS = {};
        this.CALL_STATUS_STYLES = {};
    }
    ngOnInit() {
        console.log("[record.component.ts] ngOnInit");
        let mode = "detail";
        this.appState.addToPrevRoute(this.appState.getRouteUrl());
        const data = (this.route.snapshot && this.route.snapshot.data) || {};
        console.log("[record.component.ts] route data:", data);
        if (data.mode) {
            mode = data.mode;
        }
        const params = (this.route.snapshot && this.route.snapshot.queryParams) ||
            {};
        this.recordSub = this.recordStore
            .init(this.appState.getModule(), this.route.snapshot.params.record, mode, params)
            .subscribe();
        this.vm$ = this.recordStore.vm$;
        this.vm$.pipe(takeUntil(this.destroy$)).subscribe((vm) => {
            console.log("[record.component.ts] ViewModel received");
        });
        // Load colors then setup DOM observer
        this.loadColors().then(() => {
            this.setupDomObserver();
        });
    }
    setupDomObserver() {
        // If already observing, disconnect
        if (this.domObserver) {
            this.domObserver.disconnect();
        }
        this.domObserver = new MutationObserver(() => {
            // Try each injector once per mutation batch
            this.injectCallStatusDot();
            this.injectCallStatusDotDetail();
            this.injectEditTagColors();
            this.injectDetailTagColors();
        });
        this.domObserver.observe(this.container.nativeElement, {
            childList: true,
            subtree: true,
        });
    }
    ngAfterViewInit() {
        console.log("[record.component.ts] ngAfterViewInit");
        // Initial application of styles
        this.injectCallStatusDot();
        this.injectCallStatusDotDetail();
        this.injectEditTagColors();
        this.injectDetailTagColors();
    }
    ngOnDestroy() {
        if (this.recordSub) {
            this.recordSub.unsubscribe();
        }
        if (this.modeSub) {
            this.modeSub.unsubscribe();
        }
        // Clean up observer
        if (this.domObserver) {
            this.domObserver.disconnect();
        }
        // Complete all subscriptions
        this.destroy$.next();
        this.destroy$.complete();
        this.sidebarWidgetHandler.destroy();
        this.recordStore.destroy();
    }
    async loadColors() {
        try {
            const data = await this.colorService.getColors();
            this.TAG_COLORS = data.tagColors;
            this.CALL_STATUS_STYLES = data.callStatus;
        }
        catch (error) {
            console.error("[record.component.ts] Failed to load color mappings:", error);
        }
    }
    injectCallStatusDot() {
        const container = this.container.nativeElement.querySelector(".field-name-call_status_c scrm-dropdownenum-edit select.custom-select");
        if (!container)
            return;
        for (let i = 0; i < container.options.length; i++) {
            const opt = container.options[i];
            const cleanVal = opt.value?.split(":")[1]?.trim().toLowerCase();
            const styleInfo = this.CALL_STATUS_STYLES[cleanVal];
            if (styleInfo &&
                !opt.textContent.trim().startsWith(styleInfo.emoji)) {
                opt.textContent = `${styleInfo.emoji} ${opt.textContent.trim()}`;
            }
        }
    }
    injectCallStatusDotDetail() {
        const container = this.container.nativeElement.querySelector(".field-name-call_status_c scrm-dropdownenum-detail");
        if (!container)
            return;
        const originalText = container.textContent?.trim() || "";
        const cleanVal = originalText.toLowerCase().replace(/\s+/g, "");
        const styleInfo = this.CALL_STATUS_STYLES[cleanVal];
        if (styleInfo && !originalText.startsWith(styleInfo.emoji)) {
            container.textContent = `${styleInfo.emoji} ${originalText}`;
        }
    }
    applyFlatTagStyle(el, label) {
        const color = this.TAG_COLORS[label.toLowerCase()];
        if (!color)
            return;
        el.style.backgroundColor = color;
        el.style.color = "white";
        el.style.fontSize = "12px";
        el.style.fontWeight = "bold";
        el.style.padding = "2px 8px";
        el.style.borderRadius = "12px";
        el.style.display = "inline-block";
        el.style.margin = "2px";
    }
    injectEditTagColors() {
        const wrapper = this.container.nativeElement.querySelector(".dynamic-field-name-tag_c p-multiselect");
        const tokens = this.container.nativeElement.querySelectorAll(".p-multiselect-token, .p-multiselect-item");
        if (!wrapper || tokens.length === 0)
            return;
        tokens.forEach((el) => {
            const label = el.textContent?.trim().toLowerCase();
            this.applyFlatTagStyle(el, label);
        });
        const trigger = wrapper?.querySelector(".p-multiselect-trigger");
        if (trigger) {
            // Use passive event listener for better performance
            trigger.addEventListener("click", () => {
                setTimeout(() => {
                    const items = document.querySelectorAll(".p-multiselect-item");
                    items.forEach((el) => {
                        const label = el.textContent?.trim().toLowerCase();
                        this.applyFlatTagStyle(el, label);
                    });
                }, 100);
            }, { passive: true });
        }
    }
    injectDetailTagColors() {
        const fieldWrapper = this.container.nativeElement.querySelector("scrm-field.field-name-tag_c");
        const detailItems = fieldWrapper?.querySelectorAll("scrm-multienum-detail li") || [];
        if (detailItems.length === 0)
            return;
        detailItems.forEach((el) => {
            const label = el.textContent?.trim().toLowerCase();
            this.applyFlatTagStyle(el, label);
        });
    }
    static { this.ɵfac = function RecordComponent_Factory(t) { return new (t || RecordComponent)(i0.ɵɵdirectiveInject(AppStateStore), i0.ɵɵdirectiveInject(RecordViewStore), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute), i0.ɵɵdirectiveInject(RecordViewSidebarWidgetService), i0.ɵɵdirectiveInject(ColorService)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordComponent, selectors: [["scrm-record"]], viewQuery: function RecordComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 7);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([
                RecordViewStore,
                RecordActionsAdapter,
                RecordViewSidebarWidgetService,
            ])], decls: 2, vars: 3, consts: [["class", "record-view", 4, "ngIf"], [1, "record-view"], [1, "record-view-position-sticky"], [1, "record-view-hr-container"], [1, "record-view-hr"], [4, "ngIf"]], template: function RecordComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, RecordComponent_div_0_Template, 7, 1, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, RecordContainerComponent, RecordHeaderComponent, StatusBarComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordComponent, [{
        type: Component,
        args: [{ selector: "scrm-record", providers: [
                    RecordViewStore,
                    RecordActionsAdapter,
                    RecordViewSidebarWidgetService,
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<!-- Start Record View Section -->\n<div class=\"record-view\" *ngIf=\"(vm$ | async) as vm\">\n\n    <div class=\"record-view-position-sticky\">\n        <scrm-record-header></scrm-record-header>\n    </div>\n    <div class=\"record-view-hr-container\">\n        <hr class=\"record-view-hr\">\n    </div>\n\n    <scrm-status-bar *ngIf=\"showStatusBar\"></scrm-status-bar>\n    <scrm-record-container></scrm-record-container>\n</div>\n<!-- End Record View Section -->\n" }]
    }], function () { return [{ type: AppStateStore }, { type: RecordViewStore }, { type: i1$2.ActivatedRoute }, { type: RecordViewSidebarWidgetService }, { type: ColorService }]; }, { container: [{
            type: ViewChild,
            args: ["recordContainer", { static: true }]
        }] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class RecordModule {
    static { this.ɵfac = function RecordModule_Factory(t) { return new (t || RecordModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: RecordModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            RecordContainerModule,
            RecordHeaderModule,
            StatusBarModule,
            SubpanelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordModule, [{
        type: NgModule,
        args: [{
                declarations: [RecordComponent],
                exports: [RecordComponent],
                imports: [
                    CommonModule,
                    FieldModule,
                    RecordContainerModule,
                    RecordHeaderModule,
                    StatusBarModule,
                    SubpanelModule
                ],
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(RecordModule, { declarations: [RecordComponent], imports: [CommonModule,
        FieldModule,
        RecordContainerModule,
        RecordHeaderModule,
        StatusBarModule,
        SubpanelModule], exports: [RecordComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class CreateRecordModule {
    static { this.ɵfac = function CreateRecordModule_Factory(t) { return new (t || CreateRecordModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CreateRecordModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            RecordModule,
            RecordContainerModule,
            RecordHeaderModule,
            StatusBarModule,
            SubpanelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CreateRecordModule, [{
        type: NgModule,
        args: [{
                declarations: [CreateRecordComponent],
                exports: [CreateRecordComponent],
                imports: [
                    CommonModule,
                    FieldModule,
                    RecordModule,
                    RecordContainerModule,
                    RecordHeaderModule,
                    StatusBarModule,
                    SubpanelModule
                ],
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CreateRecordModule, { declarations: [CreateRecordComponent], imports: [CommonModule,
        FieldModule,
        RecordModule,
        RecordContainerModule,
        RecordHeaderModule,
        StatusBarModule,
        SubpanelModule], exports: [CreateRecordComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallViewActionHandler extends ActionHandler {
}

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallAction extends InstallViewActionHandler {
    constructor(message, asyncActionService, router, modalService, state, localStorage) {
        super();
        this.message = message;
        this.asyncActionService = asyncActionService;
        this.router = router;
        this.modalService = modalService;
        this.state = state;
        this.localStorage = localStorage;
        this.key = 'install';
        this.modes = ['edit'];
    }
    run(data) {
        data.store.recordStore.validate().pipe(take(1)).subscribe(valid => {
            if (valid) {
                const stagingRecord = data.store.recordStore.getStaging();
                this.runInstall(stagingRecord);
                return;
            }
            this.message.addWarningMessageByKey('LBL_VALIDATION_ERRORS');
        });
    }
    shouldDisplay() {
        return true;
    }
    runInstall(stagingRecord) {
        const actionName = `suitecrm-app-${this.key}`;
        this.message.removeMessages();
        const asyncData = {
            action: actionName,
            module: stagingRecord.module,
            id: stagingRecord.id,
            payload: stagingRecord.formGroup.value
        };
        this.asyncActionService.run(actionName, asyncData).pipe(take(1)).subscribe((process) => {
            if (process.data.statusCode === 3) {
                // system validation pre-check failed; display errors modal
                this.openErrorModalDialog(process.data.errors);
            }
            // redirect to /, if request is successful
            if (process.data.statusCode === 0) {
                this.state.clear();
                this.localStorage.clear();
                this.router.navigate(['/'], {}).then();
            }
        });
    }
    openErrorModalDialog(errors) {
        const modalRef = this.modalService.open(InstallErrorModalComponent, {
            ariaLabelledBy: 'modal-basic-title',
            centered: true,
            size: 'lg',
            windowClass: 'custom-modal',
            modalDialogClass: 'custom-modal'
        });
        modalRef.componentInstance.errors = errors;
    }
    static { this.ɵfac = function InstallAction_Factory(t) { return new (t || InstallAction)(i0.ɵɵinject(MessageService), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(i1$2.Router), i0.ɵɵinject(i3$1.NgbModal), i0.ɵɵinject(StateManager), i0.ɵɵinject(LocalStorageService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallAction, factory: InstallAction.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallAction, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], function () { return [{ type: MessageService }, { type: AsyncActionService }, { type: i1$2.Router }, { type: i3$1.NgbModal }, { type: StateManager }, { type: LocalStorageService }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallActionManager extends BaseActionManager {
    constructor(save) {
        super();
        this.save = save;
        save.modes.forEach(mode => this.actions[mode][save.key] = save);
    }
    static { this.ɵfac = function InstallActionManager_Factory(t) { return new (t || InstallActionManager)(i0.ɵɵinject(InstallAction)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallActionManager, factory: InstallActionManager.ɵfac, providedIn: 'root' }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallActionManager, [{
        type: Injectable,
        args: [{
                providedIn: 'root',
            }]
    }], function () { return [{ type: InstallAction }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const initialState = {
    loading: false,
    mode: 'detail',
    params: {
        returnModule: '',
        returnId: '',
        returnAction: ''
    }
};
class InstallViewStore {
    constructor(recordFetchGQL, recordSaveGQL, message, recordManager, recordStoreFactory, language) {
        this.recordFetchGQL = recordFetchGQL;
        this.recordSaveGQL = recordSaveGQL;
        this.message = message;
        this.recordManager = recordManager;
        this.recordStoreFactory = recordStoreFactory;
        this.language = language;
        /** Internal Properties */
        this.cache$ = null;
        this.internalState = deepClone(initialState);
        this.store = new BehaviorSubject(this.internalState);
        this.state$ = this.store.asObservable();
        this.subs = [];
        this.recordStore = recordStoreFactory.create(this.getViewFieldsObservable());
        this.record$ = this.recordStore.state$.pipe(distinctUntilChanged());
        this.stagingRecord$ = this.recordStore.staging$.pipe(distinctUntilChanged());
        this.loading$ = this.state$.pipe(map(state => state.loading));
        this.mode$ = this.state$.pipe(map(state => state.mode));
        this.vm$ = this.record$.pipe(combineLatestWith(this.loading$), map(([record, loading]) => {
            this.vm = { record, loading };
            return this.vm;
        }));
        this.viewContext$ = this.record$.pipe(map(() => {
            return this.getViewContext();
        }));
    }
    get params() {
        return this.internalState.params || {};
    }
    set params(params) {
        this.updateState({
            ...this.internalState,
            params
        });
    }
    getViewContext() {
        return {
            record: this.getBaseRecord()
        };
    }
    getActions() {
        return of([]);
    }
    /**
     * Initial install view
     *
     * @param {string} mode to use
     * @param {object} params to set
     */
    init(mode = 'edit', params = {}) {
        this.setMode(mode);
        this.recordStore.init({
            id: '',
            module: 'install',
            attributes: {}
        }, true);
    }
    /**
     * Clear observable cache
     */
    clear() {
        this.cache$ = null;
        this.updateState(deepClone(initialState));
    }
    /**
     * Clear
     */
    clearAuthBased() {
        this.clear();
    }
    /**
     * Get staging record
     *
     * @returns {string} ViewMode
     */
    getBaseRecord() {
        if (!this.internalState) {
            return null;
        }
        return this.recordStore.getBaseRecord();
    }
    /**
     * Get current view mode
     *
     * @returns {string} ViewMode
     */
    getMode() {
        if (!this.internalState) {
            return null;
        }
        return this.internalState.mode;
    }
    /**
     * Set new mode
     *
     * @param {string} mode ViewMode
     */
    setMode(mode) {
        this.updateState({ ...this.internalState, mode });
    }
    getLicenseText() {
        return this.language.getFieldLabel('SUITE8_LICENSE_CONTENT');
    }
    getMetadata() {
        this.url = window.location.origin + window.location.pathname;
        this.url = trimEnd(this.url, '/');
        return {
            actions: [],
            templateMeta: {
                maxColumns: 2,
                useTabs: true,
                tabDefs: {
                    LBL_CONFIG: {
                        newTab: true,
                        panelDefault: 'expanded'
                    }
                }
            },
            panels: [
                {
                    key: 'LBL_CONFIG',
                    display$: of(true).pipe(shareReplay(1)),
                    rows: [
                        {
                            cols: [
                                {
                                    name: 'site_host',
                                    label: 'LBL_SITECFG_URL',
                                    type: 'varchar',
                                    fieldDefinition: {
                                        "name": "site_host",
                                        "vname": "LBL_SITECFG_URL",
                                        "type": "varchar",
                                        "required": true,
                                        "default": this.url?.toString(),
                                        "defaultValueModes": ["create", "edit"]
                                    },
                                },
                                {
                                    name: 'demoData',
                                    label: 'LBL_DBCONF_DEMO_DATA',
                                    type: 'enum',
                                    fieldDefinition: {
                                        name: "demoData",
                                        vname: "LBL_DBCONF_DEMO_DATA",
                                        type: "enum",
                                        options: "__no_options__",
                                        required: true,
                                        "default": 'no',
                                        "defaultValueModes": ["create", "edit"],
                                        metadata: {
                                            extraOptions: [
                                                {
                                                    value: "yes",
                                                    labelKey: "LBL_YES",
                                                },
                                                {
                                                    value: "no",
                                                    labelKey: "LBL_NO",
                                                },
                                            ]
                                        }
                                    },
                                },
                            ]
                        },
                        {
                            cols: [
                                {
                                    name: 'db_config',
                                    label: 'LBL_DBCONF_TITLE',
                                    type: 'grouped-field',
                                    fieldDefinition: {
                                        name: "db_config",
                                        vname: "LBL_DBCONF_TITLE",
                                        type: "grouped-field",
                                        layout: [
                                            "db_username",
                                            "db_password",
                                            "db_host",
                                            "db_name",
                                            "db_port"
                                        ],
                                        display: "vertical",
                                        groupFields: {
                                            "db_username": {
                                                "name": "db_username",
                                                "type": "varchar",
                                                "vname": "LBL_DBCONF_SUITE_DB_USER",
                                                "labelKey": "LBL_DBCONF_SUITE_DB_USER",
                                                "label": "LBL_DBCONF_SUITE_DB_USER",
                                                "showLabel": ["*"],
                                                "required": true,
                                            },
                                            "db_password": {
                                                "name": "db_password",
                                                "type": "password",
                                                "vname": "LBL_DBCONF_DB_PASSWORD",
                                                "labelKey": "LBL_DBCONF_DB_PASSWORD",
                                                "showLabel": ["*"],
                                                "required": true,
                                            },
                                            "db_host": {
                                                "name": "db_host",
                                                "type": "varchar",
                                                "vname": "LBL_DBCONF_HOST_NAME",
                                                "labelKey": "LBL_DBCONF_HOST_NAME",
                                                "showLabel": ["*"],
                                                "required": true,
                                            },
                                            "db_name": {
                                                "name": "db_name",
                                                "type": "varchar",
                                                "vname": "LBL_DBCONF_DB_NAME",
                                                "labelKey": "LBL_DBCONF_DB_NAME",
                                                "showLabel": ["*"],
                                                "required": true,
                                            },
                                            "db_port": {
                                                "name": "db_port",
                                                "type": "varchar",
                                                "vname": "LBL_DBCONF_DB_PORT",
                                                "labelKey": "LBL_DBCONF_DB_PORT",
                                                "showLabel": ["*"],
                                                "required": false,
                                                "default": '3306',
                                                "defaultValueModes": ["create", "edit"]
                                            }
                                        },
                                        showLabel: {
                                            edit: ['*']
                                        }
                                    },
                                },
                                {
                                    name: 'admin_config',
                                    label: 'LBL_SITECFG_TITLE',
                                    type: 'grouped-field',
                                    fieldDefinition: {
                                        name: "admin_config",
                                        vname: "LBL_SITECFG_TITLE",
                                        type: "grouped-field",
                                        layout: [
                                            "site_username",
                                            "site_password",
                                        ],
                                        display: "vertical",
                                        groupFields: {
                                            "site_username": {
                                                "name": "site_username",
                                                "type": "varchar",
                                                "vname": "LBL_SITECFG_ADMIN_Name",
                                                "labelKey": "LBL_SITECFG_ADMIN_Name",
                                                "showLabel": ["edit"],
                                                "required": true,
                                                "default": "admin",
                                                "defaultValueModes": ["create", "edit"]
                                            },
                                            "site_password": {
                                                "name": "site_password",
                                                "type": "password",
                                                "vname": "LBL_SITECFG_ADMIN_PASS",
                                                "labelKey": "LBL_SITECFG_ADMIN_PASS",
                                                "showLabel": ["edit"],
                                                "required": true,
                                            },
                                        },
                                        showLabel: {
                                            edit: ['*']
                                        }
                                    },
                                }
                            ]
                        }
                    ]
                }
            ],
        };
    }
    getMetadata$() {
        return of(this.getMetadata());
    }
    getModuleName() {
        return 'install';
    }
    /**
     * Parse query params
     *
     * @param {object} params to set
     */
    parseParams(params = {}) {
        if (!params) {
            return;
        }
        const currentParams = { ...this.internalState.params };
        Object.keys(params).forEach(paramKey => {
            if (!isVoid(currentParams[paramKey])) {
                currentParams[paramKey] = params[paramKey];
                return;
            }
        });
        this.params = params;
    }
    /**
     * Update the state
     *
     * @param {object} state to set
     */
    updateState(state) {
        this.store.next(this.internalState = state);
    }
    getIgnoreSystemChecksField() {
        return this.recordStore.getStaging().fields['sys_check_option'];
    }
    /**
     * Get view fields observable
     *
     * @returns {object} Observable<ViewFieldDefinition[]>
     */
    getViewFieldsObservable() {
        return this.getMetadata$().pipe(map((meta) => {
            const fields = [];
            meta.panels.forEach(panel => {
                panel.rows.forEach(row => {
                    row.cols.forEach(col => {
                        fields.push(col);
                    });
                });
            });
            fields.push({
                "name": "sys_check_option",
                "type": "boolean",
                fieldDefinition: {
                    "name": "sys_check_option",
                    "type": "boolean",
                    "vname": "LBL_SYS_CHECK_WARNING",
                    "labelKey": "LBL_SYS_CHECK_WARNING",
                    "showLabel": ["edit"],
                    "required": false,
                    "value": 'false',
                    "default": 'false',
                    "defaultValueModes": ["create", "edit"]
                }
            });
            return fields;
        }));
    }
    static { this.ɵfac = function InstallViewStore_Factory(t) { return new (t || InstallViewStore)(i0.ɵɵinject(RecordFetchGQL), i0.ɵɵinject(RecordSaveGQL), i0.ɵɵinject(MessageService), i0.ɵɵinject(RecordManager), i0.ɵɵinject(RecordStoreFactory), i0.ɵɵinject(LanguageStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallViewStore, factory: InstallViewStore.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallViewStore, [{
        type: Injectable
    }], function () { return [{ type: RecordFetchGQL }, { type: RecordSaveGQL }, { type: MessageService }, { type: RecordManager }, { type: RecordStoreFactory }, { type: LanguageStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallActionsAdapter extends BaseRecordActionsAdapter {
    constructor(store, metadata, language, actionManager, asyncActionService, message, confirmation, selectModalService, appMetadataStore) {
        super(actionManager, asyncActionService, message, confirmation, language, selectModalService, metadata, appMetadataStore);
        this.store = store;
        this.metadata = metadata;
        this.language = language;
        this.actionManager = actionManager;
        this.asyncActionService = asyncActionService;
        this.message = message;
        this.confirmation = confirmation;
        this.selectModalService = selectModalService;
        this.appMetadataStore = appMetadataStore;
        this.defaultActions = {
            detail: [],
            edit: [
                {
                    key: 'install',
                    labelKey: 'LBL_PROCEED',
                    params: {
                        expanded: true
                    },
                    acl: []
                },
            ],
            create: [],
        };
        this.collapseButtons = false;
    }
    getActions(context) {
        return this.store.getActions().pipe(combineLatestWith(this.store.mode$, this.store.stagingRecord$), map(([actions, mode]) => {
            if (!mode) {
                return [];
            }
            return this.parseModeActions(actions, mode, this.store.getViewContext());
        }));
    }
    buildActionData(action, context) {
        return {
            store: this.store
        };
    }
    /**
     * Build backend process input
     *
     * @param action
     * @param actionName
     * @param moduleName
     * @param context
     */
    buildActionInput(action, actionName, moduleName, context = null) {
        const baseRecord = this.store.getBaseRecord();
        this.message.removeMessages();
        return {
            action: actionName,
            module: baseRecord.module,
            id: baseRecord.id,
            record: baseRecord
        };
    }
    getMode() {
        return this.store.getMode();
    }
    getModuleName(context) {
        return this.store.getModuleName();
    }
    reload(action, process, context) {
    }
    static { this.ɵfac = function InstallActionsAdapter_Factory(t) { return new (t || InstallActionsAdapter)(i0.ɵɵinject(InstallViewStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(InstallActionManager), i0.ɵɵinject(AsyncActionService), i0.ɵɵinject(MessageService), i0.ɵɵinject(ConfirmationModalService), i0.ɵɵinject(SelectModalService), i0.ɵɵinject(AppMetadataStore)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallActionsAdapter, factory: InstallActionsAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallActionsAdapter, [{
        type: Injectable
    }], function () { return [{ type: InstallViewStore }, { type: MetadataStore }, { type: LanguageStore }, { type: InstallActionManager }, { type: AsyncActionService }, { type: MessageService }, { type: ConfirmationModalService }, { type: SelectModalService }, { type: AppMetadataStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallContentAdapter {
    constructor(store, metadata, language, actions) {
        this.store = store;
        this.metadata = metadata;
        this.language = language;
        this.actions = actions;
    }
    getEditAction() {
    }
    getDisplayConfig() {
        return this.store.getMetadata$().pipe(combineLatestWith(this.store.mode$), map(([meta, mode]) => {
            const layout = this.getLayout(meta);
            const maxColumns = meta.templateMeta.maxColumns || 2;
            const tabDefs = meta.templateMeta.tabDefs;
            return {
                layout,
                mode,
                maxColumns,
                tabDefs
            };
        }));
    }
    getPanels() {
        return this.store.getMetadata$().pipe(combineLatestWith(this.store.stagingRecord$, this.language.vm$), map(([meta, record, languages]) => {
            const panels = [];
            const module = (record && record.module) || '';
            meta.panels.forEach(panelDefinition => {
                const label = this.language.getFieldLabel(panelDefinition.key.toUpperCase(), module, languages);
                const panel = {
                    label,
                    key: panelDefinition.key,
                    display$: panelDefinition?.display$ ?? of(true).pipe(shareReplay(1)),
                    rows: []
                };
                panelDefinition.rows.forEach(rowDefinition => {
                    const row = { cols: [] };
                    rowDefinition.cols.forEach(cellDefinition => {
                        row.cols.push({ ...cellDefinition });
                    });
                    panel.rows.push(row);
                });
                panels.push(panel);
            });
            return panels;
        }));
    }
    getRecord() {
        return this.store.stagingRecord$;
    }
    getLayout(meta) {
        let layout = 'panels';
        if (meta.templateMeta.useTabs) {
            layout = 'tabs';
        }
        return layout;
    }
    static { this.ɵfac = function InstallContentAdapter_Factory(t) { return new (t || InstallContentAdapter)(i0.ɵɵinject(InstallViewStore), i0.ɵɵinject(MetadataStore), i0.ɵɵinject(LanguageStore), i0.ɵɵinject(InstallActionManager)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: InstallContentAdapter, factory: InstallContentAdapter.ɵfac }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallContentAdapter, [{
        type: Injectable
    }], function () { return [{ type: InstallViewStore }, { type: MetadataStore }, { type: LanguageStore }, { type: InstallActionManager }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallContainerComponent {
    constructor(metadata, contentAdapter) {
        this.metadata = metadata;
        this.contentAdapter = contentAdapter;
    }
    getContentAdapter() {
        return this.contentAdapter;
    }
    static { this.ɵfac = function InstallContainerComponent_Factory(t) { return new (t || InstallContainerComponent)(i0.ɵɵdirectiveInject(MetadataStore), i0.ɵɵdirectiveInject(InstallContentAdapter)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: InstallContainerComponent, selectors: [["scrm-install-container"]], features: [i0.ɵɵProvidersFeature([InstallContentAdapter])], decls: 4, vars: 1, consts: [[1, "install-view-container", "record-view-container", "view-container", "container-fluid", "pt-3", "pb-3", "small-font"], [1, "row", "no-gutters"], [1, "col"], [3, "dataSource"]], template: function InstallContainerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2);
            i0.ɵɵelement(3, "scrm-record-content", 3);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("dataSource", ctx.getContentAdapter());
        } }, dependencies: [RecordContentComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallContainerComponent, [{
        type: Component,
        args: [{ selector: 'scrm-install-container', providers: [InstallContentAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n\n<div class=\"install-view-container record-view-container view-container container-fluid pt-3 pb-3 small-font\">\n\n    <div class=\"row no-gutters\">\n\n        <div class=\"col\">\n            <scrm-record-content [dataSource]=\"getContentAdapter()\"></scrm-record-content>\n        </div>\n\n    </div>\n\n</div>\n\n" }]
    }], function () { return [{ type: MetadataStore }, { type: InstallContentAdapter }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallContainerModule {
    static { this.ɵfac = function InstallContainerModule_Factory(t) { return new (t || InstallContainerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: InstallContainerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            AngularSvgIconModule,
            RecordContentModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallContainerModule, [{
        type: NgModule,
        args: [{
                declarations: [InstallContainerComponent],
                exports: [InstallContainerComponent],
                imports: [
                    CommonModule,
                    AngularSvgIconModule,
                    RecordContentModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(InstallContainerModule, { declarations: [InstallContainerComponent], imports: [CommonModule,
        AngularSvgIconModule,
        RecordContentModule], exports: [InstallContainerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function InstallHeaderComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 1)(2, "div", 2)(3, "div", 3)(4, "div", 4);
    i0.ɵɵelement(5, "scrm-label", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "div", 6);
    i0.ɵɵelement(7, "scrm-label", 7);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(8, "div", 8)(9, "div", 9)(10, "div", 10)(11, "div", 11)(12, "div", 12)(13, "label", 13);
    i0.ɵɵelement(14, "scrm-label", 14);
    i0.ɵɵelementEnd();
    i0.ɵɵtext(15, ": ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(16, "div", 15)(17, "div", 16);
    i0.ɵɵelement(18, "scrm-field", 17);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(19, "div");
    i0.ɵɵelement(20, "scrm-action-group-menu", 18);
    i0.ɵɵelementEnd()()()()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(14);
    i0.ɵɵproperty("labelKey", ctx_r0.store.getIgnoreSystemChecksField().definition.vname);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("field", ctx_r0.store.getIgnoreSystemChecksField())("mode", "edit")("record", vm_r1.record)("type", ctx_r0.store.getIgnoreSystemChecksField().type);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("actionContext", ctx_r0.getActionContext(vm_r1.record))("config", ctx_r0.actionsAdapter);
} }
class InstallHeaderComponent {
    constructor(actionsAdapter, store) {
        this.actionsAdapter = actionsAdapter;
        this.store = store;
        this.vm$ = this.store.record$.pipe(map((record) => ({ record })));
    }
    /**
     * Build action context
     * @param record
     */
    getActionContext(record) {
        if (!record) {
            return {};
        }
        return {
            module: record.module || '',
            record
        };
    }
    getTitle() {
    }
    static { this.ɵfac = function InstallHeaderComponent_Factory(t) { return new (t || InstallHeaderComponent)(i0.ɵɵdirectiveInject(InstallActionsAdapter), i0.ɵɵdirectiveInject(InstallViewStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: InstallHeaderComponent, selectors: [["scrm-install-header"]], features: [i0.ɵɵProvidersFeature([InstallActionsAdapter])], decls: 2, vars: 3, consts: [[4, "ngIf"], [1, "install-view-header"], [1, "row", "mr-0"], [1, "col-md-4", "install-header-title-col"], [1, "install-view-title", "record-view-name"], ["labelKey", "LBL_WELCOME", "module", "install"], [1, "install-view-subtitle", "record-view-title"], ["labelKey", "LBL_INSTALL", "module", "install"], [1, "col-md-8", "install-header-buttons-col"], [1, "row", "mr-1", "ml-1"], [1, "w-100", "d-flex", "justify-content-end", "align-items-center"], [1, "w-100", "install-header-options", "d-flex", "justify-content-end", "align-items-center", "pr-5"], [1, "label-container", "pr-2"], [1, "m-0", "small"], [3, "labelKey"], [1, "d-flex"], [1, "flex-grow-1", "text-break"], [3, "field", "mode", "record", "type"], ["buttonClass", "settings-button", "klass", "install-view-actions float-right", 3, "actionContext", "config"]], template: function InstallHeaderComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, InstallHeaderComponent_ng_container_0_Template, 21, 7, "ng-container", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, ActionGroupMenuComponent, LabelComponent, FieldComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallHeaderComponent, [{
        type: Component,
        args: [{ selector: 'scrm-install-header', providers: [InstallActionsAdapter], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<ng-container *ngIf=\"(vm$ | async) as vm\">\n\n    <div class=\"install-view-header\">\n\n        <div class=\"row mr-0\">\n\n            <div class=\"col-md-4 install-header-title-col\">\n\n                <div class=\"install-view-title record-view-name\">\n                    <scrm-label labelKey=\"LBL_WELCOME\" module=\"install\"></scrm-label>\n                </div>\n                <div class=\"install-view-subtitle record-view-title\">\n                    <scrm-label labelKey=\"LBL_INSTALL\" module=\"install\"></scrm-label>\n                </div>\n\n            </div>\n\n            <div class=\"col-md-8 install-header-buttons-col\">\n\n                <div class=\"row mr-1 ml-1\">\n\n                    <div class=\"w-100 d-flex justify-content-end align-items-center\">\n\n                        <div class=\"w-100 install-header-options d-flex justify-content-end align-items-center pr-5\">\n                            <div class=\"label-container pr-2\">\n                                <label class=\"m-0 small\">\n                                    <scrm-label\n                                        [labelKey]=\"store.getIgnoreSystemChecksField().definition.vname\"></scrm-label>\n                                </label>:\n                            </div>\n                            <div class=\"d-flex\">\n                                <div class=\"flex-grow-1 text-break\">\n                                    <scrm-field [field]=\"store.getIgnoreSystemChecksField()\"\n                                                [mode]=\"'edit'\"\n                                                [record]=\"vm.record\"\n                                                [type]=\"store.getIgnoreSystemChecksField().type\">\n                                    </scrm-field>\n                                </div>\n                            </div>\n                        </div>\n\n                        <div>\n                            <scrm-action-group-menu\n                                [actionContext]=\"getActionContext(vm.record)\"\n                                [config]=\"actionsAdapter\"\n                                buttonClass=\"settings-button\"\n                                klass=\"install-view-actions float-right\"\n                            >\n                            </scrm-action-group-menu>\n                        </div>\n\n                    </div>\n\n                </div>\n\n            </div>\n\n        </div>\n\n    </div>\n</ng-container>\n" }]
    }], function () { return [{ type: InstallActionsAdapter }, { type: InstallViewStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallHeaderModule {
    static { this.ɵfac = function InstallHeaderModule_Factory(t) { return new (t || InstallHeaderModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: InstallHeaderModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModuleTitleModule,
            ActionGroupMenuModule,
            LabelModule,
            FieldModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallHeaderModule, [{
        type: NgModule,
        args: [{
                declarations: [InstallHeaderComponent],
                exports: [InstallHeaderComponent],
                imports: [
                    CommonModule,
                    ModuleTitleModule,
                    ActionGroupMenuModule,
                    LabelModule,
                    FieldModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(InstallHeaderModule, { declarations: [InstallHeaderComponent], imports: [CommonModule,
        ModuleTitleModule,
        ActionGroupMenuModule,
        LabelModule,
        FieldModule], exports: [InstallHeaderComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function InstallViewComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelement(1, "scrm-install-header");
    i0.ɵɵelementStart(2, "div", 2);
    i0.ɵɵelement(3, "hr", 3);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(4, "scrm-install-container");
    i0.ɵɵelementEnd();
} }
class InstallViewComponent {
    constructor(store, route) {
        this.store = store;
        this.route = route;
        this.vm$ = null;
        this.showStatusBar = false;
    }
    ngOnInit() {
        let mode = 'edit';
        const data = (this.route.snapshot && this.route.snapshot.data) || {};
        if (data.mode) {
            mode = data.mode;
        }
        this.store.init(mode);
        this.vm$ = this.store.vm$;
    }
    ngOnDestroy() {
        this.store.clear();
    }
    static { this.ɵfac = function InstallViewComponent_Factory(t) { return new (t || InstallViewComponent)(i0.ɵɵdirectiveInject(InstallViewStore), i0.ɵɵdirectiveInject(i1$2.ActivatedRoute)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: InstallViewComponent, selectors: [["scrm-install-view"]], features: [i0.ɵɵProvidersFeature([InstallViewStore])], decls: 2, vars: 3, consts: [["class", "install-view", 4, "ngIf"], [1, "install-view"], [1, "record-view-hr-container"], [1, "record-view-hr"]], template: function InstallViewComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, InstallViewComponent_div_0_Template, 5, 0, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i2.NgIf, InstallHeaderComponent, InstallContainerComponent, i2.AsyncPipe], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallViewComponent, [{
        type: Component,
        args: [{ selector: 'scrm-install-view', providers: [InstallViewStore], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"(vm$ | async) as vm\" class=\"install-view\">\n\n    <scrm-install-header></scrm-install-header>\n\n    <div class=\"record-view-hr-container\">\n        <hr class=\"record-view-hr\">\n    </div>\n\n    <scrm-install-container></scrm-install-container>\n</div>\n" }]
    }], function () { return [{ type: InstallViewStore }, { type: i1$2.ActivatedRoute }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class InstallViewModule {
    static { this.ɵfac = function InstallViewModule_Factory(t) { return new (t || InstallViewModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: InstallViewModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            FieldModule,
            InstallHeaderModule,
            InstallContainerModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(InstallViewModule, [{
        type: NgModule,
        args: [{
                declarations: [InstallViewComponent],
                exports: [InstallViewComponent],
                imports: [
                    CommonModule,
                    FieldModule,
                    InstallHeaderModule,
                    InstallContainerModule
                ],
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(InstallViewModule, { declarations: [InstallViewComponent], imports: [CommonModule,
        FieldModule,
        InstallHeaderModule,
        InstallContainerModule], exports: [InstallViewComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListContainerModule {
    static { this.ɵfac = function ListContainerModule_Factory(t) { return new (t || ListContainerModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ListContainerModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            TableModule,
            WidgetPanelModule,
            AngularSvgIconModule,
            SidebarWidgetModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListContainerModule, [{
        type: NgModule,
        args: [{
                declarations: [ListContainerComponent],
                exports: [ListContainerComponent],
                imports: [
                    CommonModule,
                    TableModule,
                    WidgetPanelModule,
                    AngularSvgIconModule,
                    SidebarWidgetModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ListContainerModule, { declarations: [ListContainerComponent], imports: [CommonModule,
        TableModule,
        WidgetPanelModule,
        AngularSvgIconModule,
        SidebarWidgetModule], exports: [ListContainerComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListHeaderModule {
    static { this.ɵfac = function ListHeaderModule_Factory(t) { return new (t || ListHeaderModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ListHeaderModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ModuleTitleModule,
            ActionMenuModule,
            SettingsMenuModule,
            AngularSvgIconModule,
            ListFilterModule,
            RecordPanelModule,
            ButtonGroupModule,
            LabelModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListHeaderModule, [{
        type: NgModule,
        args: [{
                declarations: [ListHeaderComponent],
                exports: [ListHeaderComponent],
                imports: [
                    CommonModule,
                    ModuleTitleModule,
                    ActionMenuModule,
                    SettingsMenuModule,
                    AngularSvgIconModule,
                    ListFilterModule,
                    RecordPanelModule,
                    ButtonGroupModule,
                    LabelModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ListHeaderModule, { declarations: [ListHeaderComponent], imports: [CommonModule,
        ModuleTitleModule,
        ActionMenuModule,
        SettingsMenuModule,
        AngularSvgIconModule,
        ListFilterModule,
        RecordPanelModule,
        ButtonGroupModule,
        LabelModule], exports: [ListHeaderComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class ListModule {
    static { this.ɵfac = function ListModule_Factory(t) { return new (t || ListModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ListModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            ListHeaderModule,
            ListContainerModule,
            FieldModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ListModule, [{
        type: NgModule,
        args: [{
                declarations: [ListComponent],
                exports: [ListComponent],
                imports: [
                    CommonModule,
                    ListHeaderModule,
                    ListContainerModule,
                    FieldModule
                ],
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ListModule, { declarations: [ListComponent], imports: [CommonModule,
        ListHeaderModule,
        ListContainerModule,
        FieldModule], exports: [ListComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
function LoginUiComponent_div_0_div_6_option_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 17);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r8 = ctx.$implicit;
    const ctx_r7 = i0.ɵɵnextContext(3);
    let tmp_0_0;
    i0.ɵɵproperty("selected", ((tmp_0_0 = ctx_r7.language) !== null && tmp_0_0 !== undefined ? tmp_0_0 : "en_us") === item_r8)("value", item_r8);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r7.getEnabledLanguages()[item_r8], " ");
} }
function LoginUiComponent_div_0_div_6_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 10)(1, "div", 5)(2, "label", 11);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd()();
    i0.ɵɵelement(4, "div", 12);
    i0.ɵɵelementStart(5, "div", 5)(6, "div", 13)(7, "select", 14, 15);
    i0.ɵɵlistener("change", function LoginUiComponent_div_0_div_6_Template_select_change_7_listener() { i0.ɵɵrestoreView(_r10); const _r6 = i0.ɵɵreference(8); const ctx_r9 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r9.onLanguageSelect(_r6.value)); });
    i0.ɵɵtemplate(9, LoginUiComponent_div_0_div_6_option_9_Template, 2, 3, "option", 16);
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(vm_r1.appStrings["LBL_LANGUAGE"]);
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("ngForOf", ctx_r3.getEnabledLanguagesKeys());
} }
function LoginUiComponent_div_0_div_8_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 28);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["ERR_MISSING_REQUIRED_FIELDS"], " ");
} }
function LoginUiComponent_div_0_div_8_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 28);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["ERR_MISSING_REQUIRED_FIELDS"], " ");
} }
function LoginUiComponent_div_0_div_8_div_13_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 29)(1, "a", 30);
    i0.ɵɵlistener("click", function LoginUiComponent_div_0_div_8_div_13_Template_a_click_1_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r19.flipCard()); });
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["LBL_LOGIN_FORGOT_PASSWORD"], " ");
} }
function LoginUiComponent_div_0_div_8_Template(rf, ctx) { if (rf & 1) {
    const _r23 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 18)(1, "div", 13);
    i0.ɵɵelement(2, "scrm-image", 19);
    i0.ɵɵelementStart(3, "input", 20, 21);
    i0.ɵɵlistener("ngModelChange", function LoginUiComponent_div_0_div_8_Template_input_ngModelChange_3_listener($event) { i0.ɵɵrestoreView(_r23); const ctx_r22 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r22.uname = $event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, LoginUiComponent_div_0_div_8_div_5_Template, 2, 1, "div", 22);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "div", 13);
    i0.ɵɵelement(7, "scrm-image", 23);
    i0.ɵɵelementStart(8, "input", 24, 25);
    i0.ɵɵlistener("ngModelChange", function LoginUiComponent_div_0_div_8_Template_input_ngModelChange_8_listener($event) { i0.ɵɵrestoreView(_r23); const ctx_r24 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r24.passw = $event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(10, LoginUiComponent_div_0_div_8_div_10_Template, 2, 1, "div", 22);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "button", 26);
    i0.ɵɵlistener("click", function LoginUiComponent_div_0_div_8_Template_button_click_11_listener() { i0.ɵɵrestoreView(_r23); i0.ɵɵnextContext(); const _r2 = i0.ɵɵreference(2); const ctx_r25 = i0.ɵɵnextContext(); _r2.control.markAllAsTouched(); return i0.ɵɵresetView(_r2.valid && ctx_r25.doLogin()); });
    i0.ɵɵtext(12);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(13, LoginUiComponent_div_0_div_8_div_13_Template, 3, 1, "div", 27);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const _r12 = i0.ɵɵreference(4);
    const _r14 = i0.ɵɵreference(9);
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("@fade", undefined);
    i0.ɵɵadvance(3);
    i0.ɵɵclassProp("is-invalid", _r12.invalid && _r12.touched);
    i0.ɵɵpropertyInterpolate("placeholder", vm_r1.appStrings["LBL_USER_NAME"]);
    i0.ɵɵproperty("ngModel", ctx_r4.uname);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", _r12.invalid && _r12.touched);
    i0.ɵɵadvance(3);
    i0.ɵɵclassProp("is-invalid", _r14.invalid && _r14.touched);
    i0.ɵɵpropertyInterpolate("placeholder", vm_r1.appStrings["LBL_PASSWORD"]);
    i0.ɵɵproperty("ngModel", ctx_r4.passw);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", _r14.invalid && _r14.touched);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("scrm-button-loading", ctx_r4.loading);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["LBL_LOGIN_BUTTON_LABEL"], " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", vm_r1.showForgotPassword);
} }
function LoginUiComponent_div_0_div_9_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 28);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["ERR_MISSING_REQUIRED_FIELDS"], " ");
} }
function LoginUiComponent_div_0_div_9_div_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 28);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vm_r1 = i0.ɵɵnextContext(2).ngIf;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["ERR_MISSING_REQUIRED_FIELDS"], " ");
} }
function LoginUiComponent_div_0_div_9_Template(rf, ctx) { if (rf & 1) {
    const _r34 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 31)(1, "div", 13);
    i0.ɵɵelement(2, "scrm-image", 19);
    i0.ɵɵelementStart(3, "input", 20, 21);
    i0.ɵɵlistener("ngModelChange", function LoginUiComponent_div_0_div_9_Template_input_ngModelChange_3_listener($event) { i0.ɵɵrestoreView(_r34); const ctx_r33 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r33.uname = $event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, LoginUiComponent_div_0_div_9_div_5_Template, 2, 1, "div", 22);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "div", 13);
    i0.ɵɵelement(7, "scrm-image", 32);
    i0.ɵɵelementStart(8, "input", 33, 34);
    i0.ɵɵlistener("ngModelChange", function LoginUiComponent_div_0_div_9_Template_input_ngModelChange_8_listener($event) { i0.ɵɵrestoreView(_r34); const ctx_r35 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r35.email = $event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(10, LoginUiComponent_div_0_div_9_div_10_Template, 2, 1, "div", 22);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "button", 35);
    i0.ɵɵlistener("click", function LoginUiComponent_div_0_div_9_Template_button_click_11_listener() { i0.ɵɵrestoreView(_r34); i0.ɵɵnextContext(); const _r2 = i0.ɵɵreference(2); const ctx_r36 = i0.ɵɵnextContext(); _r2.control.markAllAsTouched(); return i0.ɵɵresetView(_r2.valid && ctx_r36.recoverPassword()); });
    i0.ɵɵtext(12);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(13, "div")(14, "a", 36);
    i0.ɵɵlistener("click", function LoginUiComponent_div_0_div_9_Template_a_click_14_listener() { i0.ɵɵrestoreView(_r34); const ctx_r37 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r37.flipCard()); });
    i0.ɵɵtext(15);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const _r27 = i0.ɵɵreference(4);
    const _r29 = i0.ɵɵreference(9);
    const vm_r1 = i0.ɵɵnextContext().ngIf;
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵproperty("@fade", undefined);
    i0.ɵɵadvance(3);
    i0.ɵɵclassProp("is-invalid", _r27.invalid && _r27.touched);
    i0.ɵɵpropertyInterpolate("placeholder", vm_r1.appStrings["LBL_USER_NAME"]);
    i0.ɵɵproperty("ngModel", ctx_r5.uname);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", _r27.invalid && _r27.touched);
    i0.ɵɵadvance(3);
    i0.ɵɵclassProp("is-invalid", _r29.invalid && _r29.touched);
    i0.ɵɵpropertyInterpolate("placeholder", vm_r1.appStrings["LBL_EMAIL"]);
    i0.ɵɵproperty("ngModel", ctx_r5.email);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", _r29.invalid && _r29.touched);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["LBL_GENERATE_PASSWORD_BUTTON_TITLE"], " ");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", vm_r1.appStrings["LBL_BACK"], " ");
} }
function LoginUiComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "form", 2, 3)(3, "div", 4)(4, "div", 5);
    i0.ɵɵelement(5, "scrm-logo-ui");
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(6, LoginUiComponent_div_0_div_6_Template, 10, 2, "div", 6);
    i0.ɵɵelementStart(7, "div", 7);
    i0.ɵɵtemplate(8, LoginUiComponent_div_0_div_8_Template, 14, 14, "div", 8);
    i0.ɵɵtemplate(9, LoginUiComponent_div_0_div_9_Template, 16, 13, "div", 9);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const vm_r1 = ctx.ngIf;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("ngIf", vm_r1.showLanguages);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.cardState === "front");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.cardState === "back");
} }
class LoginUiComponent {
    constructor(router, auth, message, configs, languageStore, recoverPasswordService, appState) {
        this.router = router;
        this.auth = auth;
        this.message = message;
        this.configs = configs;
        this.languageStore = languageStore;
        this.recoverPasswordService = recoverPasswordService;
        this.appState = appState;
        this.hidden = true;
        this.loading = false;
        this.error = '';
        this.uname = '';
        this.passw = '';
        this.email = '';
        this.cardState = 'front';
        this.systemConfigs$ = this.configs.configs$;
        this.appStrings$ = this.languageStore.appStrings$;
        this.language = null;
        this.vm$ = this.systemConfigs$.pipe(combineLatestWith(this.appStrings$), map(([systemConfigs, appStrings]) => {
            let showLanguages = false;
            let showForgotPassword = false;
            if (systemConfigs.languages && systemConfigs.languages.items && systemConfigs.login_language.value) {
                showLanguages = Object.keys(systemConfigs.languages.items).length > 1;
            }
            if (systemConfigs.passwordsetting && systemConfigs.passwordsetting.items) {
                const forgotPasswordProperty = systemConfigs.passwordsetting.items.forgotpasswordON;
                showForgotPassword = [true, '1', 'true'].includes(forgotPasswordProperty);
            }
            return {
                systemConfigs,
                appStrings,
                showLanguages,
                showForgotPassword
            };
        }));
        this.loading = false;
        this.hidden = false;
        this.language = null;
    }
    ngOnInit() {
        this.setCurrentLanguage();
        this.appState.removeAllPrevRoutes();
    }
    onLanguageSelect(language) {
        if (!language) {
            return;
        }
        if (language === this.language) {
            return;
        }
        this.changeLanguage(language);
    }
    changeLanguage(language) {
        this.language = language;
        let languagesLoading = false;
        if (this?.appState?.updateLoading) {
            this.appState.updateLoading('change-language', true);
            languagesLoading = true;
        }
        this.languageStore.changeLanguage(language, true).pipe(tap(() => {
            if (languagesLoading) {
                this.appState.updateLoading('change-language', false);
            }
        })).subscribe();
    }
    getEnabledLanguages() {
        return this.languageStore.getEnabledLanguages();
    }
    getEnabledLanguagesKeys() {
        return Object.keys(this.languageStore.getEnabledLanguages() ?? {}) ?? [];
    }
    flipCard() {
        if (this.cardState === 'front') {
            this.cardState = 'back';
        }
        else {
            this.cardState = 'front';
        }
    }
    doLogin() {
        this.loading = true;
        this.auth.doLogin(this.uname, this.passw, this.onLoginSuccess.bind(this), this.onLoginError.bind(this));
    }
    recoverPassword() {
        this.recoverPasswordService
            .run(this.uname, this.email)
            .subscribe((process) => {
            this.message.log('Recover Password Status: ' + process.status);
            let handler = 'addSuccessMessageByKey';
            if (process.status === 'error') {
                handler = 'addDangerMessageByKey';
            }
            if (process.messages) {
                process.messages.forEach(message => {
                    this.message[handler](message);
                });
            }
        }, () => {
            this.message.log('Recover Password failed');
            this.message.addDangerMessageByKey('ERR_AJAX_LOAD_FAILURE');
        });
    }
    onLoginSuccess(result) {
        this.loading = false;
        this.message.log('Login success');
        this.message.removeMessages();
        this.languageStore.setSessionLanguage()
            .pipe(catchError(() => of({})))
            .subscribe(() => {
            if (result && result.redirect && result.redirect.route) {
                this.router.navigate([result.redirect.route], {
                    queryParams: result.redirect.queryParams ?? {}
                }).then();
                return;
            }
            if (this.appState.getPreLoginUrl()) {
                this.router.navigateByUrl(this.appState.getPreLoginUrl()).then(() => {
                    this.appState.setPreLoginUrl('');
                });
                return;
            }
            const defaultModule = this.configs.getHomePage();
            this.router.navigate(['/' + defaultModule]).then();
        });
        if (this.configs.getConfigValue('login_language')) {
            this.languageStore.setUserLanguage().subscribe();
        }
        return;
    }
    onLoginError(httpError) {
        this.loading = false;
        this.message.log('Login failed');
        const defaultMessage = 'Login credentials incorrect, please try again.';
        const defaultTooManyFailedMessage = 'Too many failed login attempts, please try again later.';
        let message = this.languageStore.getFieldLabel('LOGIN_INCORRECT');
        const errorMessage = httpError?.error?.error ?? '';
        if (typeof errorMessage === 'string' && errorMessage.includes('Too many failed login attempts, please try again in')) {
            message = this.getTooManyFailedMessage(defaultTooManyFailedMessage);
        }
        if (!message) {
            message = defaultMessage;
        }
        this.message.addDangerMessage(message);
    }
    getTooManyFailedMessage(defaultTooManyFailedMessage) {
        let tooManyFailedMessage = this.languageStore.getFieldLabel('LOGIN_TOO_MANY_FAILED');
        if (!tooManyFailedMessage) {
            tooManyFailedMessage = defaultTooManyFailedMessage;
        }
        return tooManyFailedMessage;
    }
    setCurrentLanguage() {
        let currentLanguage = this.languageStore.getSelectedLanguage() ?? '';
        const activeLanguage = this.languageStore.getActiveLanguage();
        if (!currentLanguage) {
            currentLanguage = activeLanguage;
        }
        if (!this.languageStore.isLanguageEnabled(currentLanguage)) {
            currentLanguage = '';
        }
        if (this.language && currentLanguage === this.language) {
            return;
        }
        const defaultLanguage = this.configs.getConfigValue('default_language') ?? 'en_us';
        if (!currentLanguage) {
            currentLanguage = defaultLanguage;
        }
        if (!this.languageStore.isLanguageEnabled(currentLanguage)) {
            currentLanguage = this.languageStore.getFirstLanguage();
        }
        this.language = currentLanguage;
        this.changeLanguage(currentLanguage);
    }
    static { this.ɵfac = function LoginUiComponent_Factory(t) { return new (t || LoginUiComponent)(i0.ɵɵdirectiveInject(i1$2.Router), i0.ɵɵdirectiveInject(AuthService), i0.ɵɵdirectiveInject(MessageService), i0.ɵɵdirectiveInject(SystemConfigStore), i0.ɵɵdirectiveInject(LanguageStore), i0.ɵɵdirectiveInject(RecoverPasswordService), i0.ɵɵdirectiveInject(AppStateStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LoginUiComponent, selectors: [["scrm-login-ui"]], decls: 2, vars: 3, consts: [["class", "login-view full-height-view d-flex align-items-center", 4, "ngIf"], [1, "login-view", "full-height-view", "d-flex", "align-items-center"], ["name", "login", 1, "login-form"], ["loginForm", "ngForm"], [1, "form-row", "form-group"], [1, "col"], ["class", "form-row", 4, "ngIf"], [1, "form-row", "fade-card"], ["class", "fade-card-front col", 4, "ngIf"], ["class", "fade-card-back col", 4, "ngIf"], [1, "form-row"], ["for", "languages", 1, ""], [1, "w-100"], [1, "inner-addon", "left-addon"], ["id", "languages", 3, "change"], ["languageSelect", ""], [3, "selected", "value", 4, "ngFor", "ngForOf"], [3, "selected", "value"], [1, "fade-card-front", "col"], ["image", "login_user"], ["type", "text", "name", "username", "aria-label", "Username", "required", "", 3, "ngModel", "placeholder", "ngModelChange"], ["username", "ngModel"], ["class", "invalid-feedback", 4, "ngIf"], ["image", "login_password"], ["type", "password", "name", "password", "aria-label", "Password", "required", "", 3, "ngModel", "placeholder", "ngModelChange"], ["password", "ngModel"], ["id", "login-button", 1, "login-button", 3, "scrm-button-loading", "click"], ["class", "forgotten-password", 4, "ngIf"], [1, "invalid-feedback"], [1, "forgotten-password"], [1, "forgotten-password-link", 3, "click"], [1, "fade-card-back", "col"], ["image", "email"], ["type", "email", "name", "email", "aria-label", "Email", "required", "", 3, "ngModel", "placeholder", "ngModelChange"], ["mail", "ngModel"], ["scrm-button-loading", "", 1, "submit-button", "login-button", 3, "click"], [1, "back-link", "forgotten-password-link", 3, "click"]], template: function LoginUiComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, LoginUiComponent_div_0_Template, 10, 3, "div", 0);
            i0.ɵɵpipe(1, "async");
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, ctx.vm$));
        } }, dependencies: [i5$1.ɵNgNoValidate, i5$1.NgSelectOption, i5$1.ɵNgSelectMultipleOption, i5$1.DefaultValueAccessor, i5$1.NgControlStatus, i5$1.NgControlStatusGroup, i5$1.RequiredValidator, i5$1.NgModel, i5$1.NgForm, LogoUiComponent, i2.NgForOf, i2.NgIf, ImageComponent, ButtonLoadingDirective, i2.AsyncPipe], encapsulation: 2, data: { animation: [
                trigger('fade', [
                    transition(':enter', useAnimation(fadeIn, {
                        params: { timing: 0.5, delay: 0 }
                    })),
                ])
            ] } }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoginUiComponent, [{
        type: Component,
        args: [{ selector: 'scrm-login-ui', animations: [
                    trigger('fade', [
                        transition(':enter', useAnimation(fadeIn, {
                            params: { timing: 0.5, delay: 0 }
                        })),
                    ])
                ], template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2021 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div *ngIf=\"(vm$ | async) as vm\" class=\"login-view full-height-view d-flex align-items-center\">\n\n    <!-- Start of login form section -->\n\n    <form name=\"login\" class=\"login-form\" #loginForm=\"ngForm\">\n        <div class=\"form-row form-group\">\n            <div class=\"col\">\n                <scrm-logo-ui></scrm-logo-ui>\n            </div>\n        </div>\n        <div class=\"form-row\" *ngIf=\"vm.showLanguages\">\n            <div class=\"col\">\n                <label class=\"\" for=\"languages\">{{vm.appStrings['LBL_LANGUAGE']}}</label>\n            </div>\n            <div class=\"w-100\"></div>\n            <div class=\"col\">\n                <div class=\"inner-addon left-addon\">\n                    <select #languageSelect id=\"languages\"\n                            (change)=\"onLanguageSelect(languageSelect.value)\">\n                        <option *ngFor=\"let item of getEnabledLanguagesKeys()\"\n                                [selected]=\"(language ?? 'en_us') === item\"\n                                [value]=\"item\">\n                            {{getEnabledLanguages()[item]}}\n                        </option>\n                    </select>\n                </div>\n            </div>\n        </div>\n\n\n        <div class=\"form-row fade-card\">\n\n            <!-- Card front -->\n            <div class=\"fade-card-front col\"\n                 *ngIf=\"cardState==='front'\"\n                 [@fade]>\n\n                <div class=\"inner-addon left-addon\">\n                    <scrm-image image=\"login_user\"></scrm-image>\n                    <input [(ngModel)]=\"uname\"\n                           type=\"text\"\n                           name=\"username\"\n                           [class.is-invalid]=\"username.invalid && username.touched\"\n                           #username=\"ngModel\"\n                           placeholder=\"{{vm.appStrings['LBL_USER_NAME']}}\"\n                           aria-label=\"Username\"\n                           required>\n                    <div *ngIf=\"username.invalid && username.touched\" class=\"invalid-feedback\">\n                        {{vm.appStrings['ERR_MISSING_REQUIRED_FIELDS']}}\n                    </div>\n                </div>\n\n                <div class=\"inner-addon left-addon\">\n                    <scrm-image image=\"login_password\"></scrm-image>\n                    <input [(ngModel)]=\"passw\"\n                           type=\"password\"\n                           name=\"password\"\n                           [class.is-invalid]=\"password.invalid && password.touched\"\n                           #password=\"ngModel\"\n                           placeholder=\"{{vm.appStrings['LBL_PASSWORD']}}\"\n                           aria-label=\"Password\"\n                           required>\n                    <div *ngIf=\"password.invalid && password.touched\" class=\"invalid-feedback\">\n                        {{vm.appStrings['ERR_MISSING_REQUIRED_FIELDS']}}\n                    </div>\n                </div>\n\n\n                <button id=\"login-button\" class=\"login-button\"\n                        [scrm-button-loading]=\"loading\"\n                        (click)=\"loginForm.control.markAllAsTouched(); loginForm.valid && doLogin()\">\n                    {{vm.appStrings['LBL_LOGIN_BUTTON_LABEL']}}\n                </button>\n                <div class=\"forgotten-password\" *ngIf=\"vm.showForgotPassword\">\n                    <a class=\"forgotten-password-link\" (click)=\"flipCard()\">\n                        {{vm.appStrings['LBL_LOGIN_FORGOT_PASSWORD']}}\n                    </a>\n                </div>\n\n            </div>\n\n            <!-- Card back-->\n            <div class=\"fade-card-back col\"\n                 *ngIf=\"cardState==='back'\"\n                 [@fade]>\n                <div class=\"inner-addon left-addon\">\n                    <scrm-image image=\"login_user\"></scrm-image>\n                    <input [(ngModel)]=\"uname\"\n                           type=\"text\"\n                           name=\"username\"\n                           [class.is-invalid]=\"username.invalid && username.touched\"\n                           #username=\"ngModel\"\n                           placeholder=\"{{vm.appStrings['LBL_USER_NAME']}}\"\n                           aria-label=\"Username\"\n                           required>\n                    <div *ngIf=\"username.invalid && username.touched\" class=\"invalid-feedback\">\n                        {{vm.appStrings['ERR_MISSING_REQUIRED_FIELDS']}}\n                    </div>\n                </div>\n\n                <div class=\"inner-addon left-addon\">\n                    <scrm-image image=\"email\"></scrm-image>\n                    <input [(ngModel)]=\"email\"\n                           type=\"email\"\n                           name=\"email\"\n                           [class.is-invalid]=\"mail.invalid && mail.touched\"\n                           #mail=\"ngModel\"\n                           placeholder=\"{{vm.appStrings['LBL_EMAIL']}}\"\n                           aria-label=\"Email\"\n                           required>\n                    <div *ngIf=\"mail.invalid && mail.touched\" class=\"invalid-feedback\">\n                        {{vm.appStrings['ERR_MISSING_REQUIRED_FIELDS']}}\n                    </div>\n                </div>\n\n                <button class=\"submit-button login-button\"\n                        scrm-button-loading\n                        (click)=\"loginForm.control.markAllAsTouched(); loginForm.valid && recoverPassword()\">\n                    {{vm.appStrings['LBL_GENERATE_PASSWORD_BUTTON_TITLE']}}\n                </button>\n                <div>\n                    <a class=\"back-link forgotten-password-link\" (click)=\"flipCard()\">\n                        {{vm.appStrings['LBL_BACK']}}\n                    </a>\n                </div>\n            </div>\n        </div>\n    </form>\n\n    <!-- End of login form section -->\n\n</div>\n\n<!-- End of login component section -->\n" }]
    }], function () { return [{ type: i1$2.Router }, { type: AuthService }, { type: MessageService }, { type: SystemConfigStore }, { type: LanguageStore }, { type: RecoverPasswordService }, { type: AppStateStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
const LoginUiRoutes = [
    {
        path: '',
        component: LoginUiComponent
    }
];

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LoginUiModule {
    static { this.ɵfac = function LoginUiModule_Factory(t) { return new (t || LoginUiModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LoginUiModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [FormsModule,
            LogoUiModule,
            RouterModule.forChild(LoginUiRoutes),
            CommonModule,
            AngularSvgIconModule,
            ImageModule,
            ButtonLoadingUiModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoginUiModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    LoginUiComponent
                ],
                exports: [
                    LoginUiComponent
                ],
                imports: [
                    FormsModule,
                    LogoUiModule,
                    RouterModule.forChild(LoginUiRoutes),
                    CommonModule,
                    AngularSvgIconModule,
                    ImageModule,
                    ButtonLoadingUiModule
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LoginUiModule, { declarations: [LoginUiComponent], imports: [FormsModule,
        LogoUiModule, i1$2.RouterModule, CommonModule,
        AngularSvgIconModule,
        ImageModule,
        ButtonLoadingUiModule], exports: [LoginUiComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2022 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoutComponent {
    constructor(configs) {
        this.configs = configs;
    }
    getLoginURL() {
        return './';
    }
    static { this.ɵfac = function LogoutComponent_Factory(t) { return new (t || LogoutComponent)(i0.ɵɵdirectiveInject(SystemConfigStore)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LogoutComponent, selectors: [["scrm-logout"]], decls: 11, vars: 1, consts: [[1, "logged-out-view", "full-height-view", "d-flex", "flex-column", "align-items-center", "justify-content-center"], [1, "logo-row", "full-height-view-row"], [1, "mt-3", "mb-1", "page-title", "full-height-view-row"], ["labelKey", "LBL_LOGGED_OUT_MESSAGE"], [1, "page-subtitle", "full-height-view-row"], ["labelKey", "LBL_LOGIN_AGAIN"], [1, "text-lowercase", 3, "href"], ["labelKey", "LBL_CLICK_HERE"]], template: function LogoutComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "div", 1);
            i0.ɵɵelement(2, "scrm-logo-ui");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(3, "div", 2)(4, "h2");
            i0.ɵɵelement(5, "scrm-label", 3);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(6, "div", 4)(7, "h5");
            i0.ɵɵelement(8, "scrm-label", 5);
            i0.ɵɵelementStart(9, "a", 6);
            i0.ɵɵelement(10, "scrm-label", 7);
            i0.ɵɵelementEnd()()()();
        } if (rf & 2) {
            i0.ɵɵadvance(9);
            i0.ɵɵproperty("href", ctx.getLoginURL(), i0.ɵɵsanitizeUrl);
        } }, dependencies: [LabelComponent, LogoUiComponent], encapsulation: 2 }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoutComponent, [{
        type: Component,
        args: [{ selector: 'scrm-logout', template: "<! --\n/**\n* SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.\n* Copyright (C) 2022 SalesAgility Ltd.\n*\n* This program is free software; you can redistribute it and/or modify it under\n* the terms of the GNU Affero General Public License version 3 as published by the\n* Free Software Foundation with the addition of the following permission added\n* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK\n* IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE\n* WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.\n*\n* This program is distributed in the hope that it will be useful, but WITHOUT\n* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more\n* details.\n*\n* You should have received a copy of the GNU Affero General Public License\n* along with this program.  If not, see http://www.gnu.org/licenses.\n*\n* In accordance with Section 7(b) of the GNU Affero General Public License\n* version 3, these Appropriate Legal Notices must retain the display of the\n* \"Supercharged by SuiteCRM\" logo. If the display of the logos is not reasonably\n* feasible for technical reasons, the Appropriate Legal Notices must display\n* the words \"Supercharged by SuiteCRM\".\n*/\n-->\n<div class=\"logged-out-view full-height-view d-flex flex-column align-items-center justify-content-center\">\n\n    <div class=\"logo-row full-height-view-row\">\n        <scrm-logo-ui></scrm-logo-ui>\n    </div>\n    <div class=\"mt-3 mb-1 page-title full-height-view-row\">\n        <h2>\n            <scrm-label labelKey=\"LBL_LOGGED_OUT_MESSAGE\"></scrm-label>\n        </h2>\n    </div>\n    <div class=\"page-subtitle full-height-view-row\">\n        <h5>\n            <scrm-label labelKey=\"LBL_LOGIN_AGAIN\"></scrm-label><a class=\"text-lowercase\" [href]=\"getLoginURL()\"><scrm-label labelKey=\"LBL_CLICK_HERE\"></scrm-label></a>\n        </h5>\n    </div>\n</div>\n" }]
    }], function () { return [{ type: SystemConfigStore }]; }, null); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2022 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */
class LogoutModule {
    static { this.ɵfac = function LogoutModule_Factory(t) { return new (t || LogoutModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: LogoutModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
            LabelModule,
            LogoUiModule] }); }
}
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LogoutModule, [{
        type: NgModule,
        args: [{
                declarations: [
                    LogoutComponent
                ],
                exports: [
                    LogoutComponent
                ],
                imports: [
                    CommonModule,
                    LabelModule,
                    LogoUiModule,
                ]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(LogoutModule, { declarations: [LogoutComponent], imports: [CommonModule,
        LabelModule,
        LogoUiModule], exports: [LogoutComponent] }); })();

/**
 * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
 * Copyright (C) 2021 SalesAgility Ltd.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Supercharged by SuiteCRM".
 */

/*
 * Public API Surface of core
 */

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

export { ActionGroupMenuComponent, ActionGroupMenuModule, ActionLogicHandler, ActionMenuComponent, ActionMenuModule, ActionNameMapper, ActiveFieldsChecker, AdminCardComponent, AdminCardModule, AdminMetadataStore, AdminPanelComponent, AdminPanelModule, AppMetadataStore, AppStateStore, AsyncActionHandler, AsyncActionService, AsyncProcessLineAction, AsyncProcessRecordAction, AsyncProcessRecordThreadItemAction, AsyncProcessRecordThreadListAction, AsyncProcessSubpanelAction, AsyncProcessSubpanelLineAction, AsyncProcessTableAction, AttributeBuilder, AuthGuard, AuthService, BaseActionManager, BaseActionsAdapter, BaseBooleanComponent, BaseChartComponent, BaseChartModule, BaseComposite, BaseDateComponent, BaseDateTimeComponent, BaseEnumComponent, BaseFavoritesComponent, BaseFieldComponent, BaseFieldGridComponent, BaseFieldModule, BaseFieldRegistry, BaseGroupedMenuItemComponent, BaseHomeMenuItemComponent, BaseLineActionsAdapter, BaseLineItemsComponent, BaseMenuFavoritesComponent, BaseMenuItemComponent, BaseMenuItemLinkComponent, BaseMenuItemsListComponent, BaseMenuRecentlyViewedComponent, BaseMetadataResolver, BaseModuleResolver, BaseMultiEnumComponent, BaseNameComponent, BaseNavbarComponent, BaseNumberComponent, BaseRecordActionsAdapter, BaseRecordContainerStore, BaseRecordResolver, BaseRelateComponent, BaseRouteService, BaseSaveRecordMapper, BaseSubMenuFavoritesComponent, BaseSubMenuRecentlyViewedComponent, BaseWidgetComponent, BaseWidgetModule, BooleanDetailFieldComponent, BooleanDetailFieldModule, BooleanEditFieldComponent, BooleanEditFieldModule, BottomWidgetAdapter, BulkActionMenuComponent, BulkActionMenuModule, BulkActionsAdapter, BulkActionsAdapterFactory, ButtonComponent, ButtonGroupComponent, ButtonGroupModule, ButtonLoadingDirective, ButtonLoadingUiModule, ButtonModule, ButtonUtils, CancelCreateAction, CancelRecordPanelAction, ChangelogAsyncAction, ChartComponent, ChartDataStore, ChartDataStoreFactory, ChartMessageAreaComponent, ChartMessageAreaModule, ChartModule, ChartRegistry, ChartSidebarWidgetComponent, ChartSidebarWidgetModule, ClassicModalComponent, ClassicModalModule, ClassicViewResolver, ClassicViewUiComponent, ClassicViewUiModule, CloseButtonComponent, CloseButtonModule, CollectionGQL, ColorService, ColumnChooserComponent, ColumnChooserModule, CompositeComponent, CompositeModule, ConditionOperatorActionHandler, ConditionOperatorManager, ConfirmationModalService, CreateRecordComponent, CreateRecordModule, CreateRelatedLineAction, CreateViewStore, CurrencyDetailFieldComponent, CurrencyDetailFieldModule, CurrencyFormatter, CurrencyService, CurrencyUnitConverter, CurrencyValidator, DataTypeFormatter, DataTypeSeriesMapper, DataTypeUnitConverter, DateAdapter, DateDetailFieldComponent, DateDetailFieldModule, DateEditFieldComponent, DateEditFieldModule, DateFilterFieldComponent, DateFilterFieldModule, DateFormatter, DateParserFormatter, DateTimeDetailFieldComponent, DateTimeDetailFieldModule, DateTimeEditFieldComponent, DateTimeEditFieldModule, DateTimeFilterFieldComponent, DateTimeFilterFieldModule, DateTimeModel, DateTimeValidator, DateValidator, DatetimeFormatter, DisplayTypeAction, DisplayTypeBackendAction, DropdownButtonComponent, DropdownButtonModule, DropdownEnumDetailFieldComponent, DropdownEnumDetailFieldModule, DropdownEnumEditFieldComponent, DropdownEnumEditFieldModule, DropdownSubmenuComponent, DropdownSubmenuModule, DuplicateEmailValidator, DynamicFieldComponent, DynamicFieldModule, DynamicLabelComponent, DynamicLabelModule, DynamicLabelService, EmailDetailFieldsComponent, EmailDetailFieldsModule, EmailFormatter, EmailListFieldsComponent, EmailListFieldsModule, EmailPrimarySelectAction, EmailValidator, EntityGQL, EntityMutationGQL, EnumDetailFieldComponent, EnumDetailFieldModule, EnumEditFieldComponent, EnumEditFieldModule, ErrorInterceptor, ExportAsyncAction, ExtensionLoader, FavoriteToggleComponent, FavoriteToggleModule, FavoritesService, FieldBuilder, FieldComponent, FieldGridComponent, FieldGridModule, FieldLayoutComponent, FieldLayoutModule, FieldLogicActionHandler, FieldLogicDisplayActionHandler, FieldLogicDisplayManager, FieldLogicDisplayTypeAction, FieldLogicManager, FieldManager, FieldModule, FieldObjectRegistry, FieldRegistry, FileDetailFieldComponent, FileDetailFieldModule, FilterAdapter, FilterAttributeBuilder, FilterFieldBuilder, FilterListStore, FilterListStoreFactory, FiltersListGQL, FloatDetailFieldComponent, FloatDetailFieldModule, FloatValidator, FooterUiComponent, FooterUiModule, FormControlUtils, FormatCurrencyModule, FormatCurrencyPipe, FormatNumberModule, FormatNumberPipe, FullNameDetailFieldsComponent, FullNameDetailFieldsModule, FullPageSpinnerComponent, FullPageSpinnerModule, GlobalRecentlyViewedStore, GlobalSearch, GreaterThanAction, GridWidgetComponent, GridWidgetModule, GroupFieldBuilder, GroupFieldComponent, GroupFieldModule, GroupedButtonComponent, GroupedButtonModule, GroupedMenuItemComponent, GroupedMenuItemRegistry, HistorySidebarWidgetComponent, HistorySidebarWidgetModule, HistoryTimelineAdapter, HistoryTimelineAdapterFactory, HistoryTimelineStore, HistoryTimelineStoreFactory, HomeMenuItemComponent, HomeMenuItemRegistry, HtmlDetailFieldComponent, HtmlDetailFieldModule, HtmlSanitizeModule, HtmlSanitizePipe, IconDetailFieldComponent, IconListFieldModule, IframePageChangeObserver, IframeResizeHandlerHandler, ImageComponent, ImageModule, ImmediateDebounce, InlineLoadingSpinnerComponent, InlineLoadingSpinnerModule, InstallAction, InstallActionManager, InstallActionsAdapter, InstallAuthGuard, InstallContainerComponent, InstallContainerModule, InstallContentAdapter, InstallErrorModalComponent, InstallErrorModalModule, InstallHeaderComponent, InstallHeaderModule, InstallViewActionHandler, InstallViewComponent, InstallViewModule, InstallViewStore, IntDetailFieldComponent, IntDetailFieldModule, IntValidator, IsEmptyAction, IsEqualAction, LabelComponent, LabelModule, LanguageStore, LegacyEntrypointLinkBuilder, LessThanAction, LineActionActionHandler, LineActionActionManager, LineActionMenuComponent, LineActionModule, LineActionsAdapter, LineChartComponent, LineChartModule, LineItemBuilder, LineItemsComponent, LineItemsModule, LinkModel, LinkRouteAsyncActionService, LinkTarget, ListComponent, ListContainerComponent, ListContainerModule, ListFilterComponent, ListFilterModule, ListFilterStore, ListFilterStoreFactory, ListGQL, ListHeaderComponent, ListHeaderModule, ListModule, ListViewRecordPanelActionAdapterFactory, ListViewRecordPanelActionHandler, ListViewRecordPanelActionsAdapter, ListViewSidebarWidgetAdapter, ListViewSidebarWidgetService, ListViewStore, ListViewTableActionsAdapter, ListViewUrlQueryService, ListviewTableActionsAdapterFactory, LoadMoreComponent, LoadMoreModule, LoadingBuffer, LoadingBufferFactory, LoadingSpinnerComponent, LoadingSpinnerModule, LocalStorageService, LoginAuthGuard, LoginUiComponent, LoginUiModule, LoginUiRoutes, LogoAbstract, LogoUiComponent, LogoUiModule, LogoutComponent, LogoutModule, LogoutUiComponent, LogoutUiModule, MaxColumnsCalculator, MenuFavoritesComponent, MenuFavoritesRegistry, MenuItemComponent, MenuItemLinkComponent, MenuItemLinkRegistry, MenuItemRegistry, MenuItemsListComponent, MenuItemsListRegistry, MenuRecentlyViewedComponent, MenuRecentlyViewedRegistry, MessageModalComponent, MessageModalModule, MessageService, MessageUiComponent, MessageUiModule, MetadataStore, MinimiseButtonComponent, MinimiseButtonModule, MobileMenuComponent, ModalButtonGroupComponent, ModalButtonGroupModule, ModalComponent, ModalModule, ModalRecordFilterAdapter, ModalRecordListTableAdapter, ModuleNameMapper, ModuleNavigation, ModuleTitleComponent, ModuleTitleModule, MultiEnumDetailFieldComponent, MultiEnumDetailFieldModule, MultiEnumEditFieldComponent, MultiEnumEditFieldModule, MultiEnumField, MultiEnumFilterFieldComponent, MultiEnumFilterFieldModule, NavbarAbstract, NavbarRegistry, NavbarUiComponent, NavbarUiModule, NavigationStore, NoopAsyncAction, NotEmptyAction, NotEqualAction, NotificationStore, NotificationsComponent, NotificationsModule, NotificationsService, NumberFormatter, PaginationComponent, PaginationModule, PanelComponent, PanelLogicActionHandler, PanelLogicDisplayTypeAction, PanelLogicManager, PanelModule, PasswordDetailFieldComponent, PasswordDetailFieldModule, PasswordEditFieldComponent, PasswordEditFieldModule, PhoneDetailFieldComponent, PhoneDetailFieldModule, PhoneFormatter, PhoneValidator, PieGridChartComponent, PieGridChartModule, PopupButtonComponent, PopupButtonModule, PrimaryEmailValidator, ProcessService, QuickFiltersService, RadioEnumDetailFieldComponent, RadioEnumDetailFieldModule, RadioEnumEditFieldComponent, RadioEnumEditFieldModule, RangeValidator, RecentlyViewedComponent, RecentlyViewedService, RecordActionDisplayTypeLogic, RecordActionHandler, RecordActionManager, RecordActionsAdapter, RecordCancelAction, RecordComponent, RecordContainerComponent, RecordContainerModule, RecordContentAdapter, RecordContentComponent, RecordContentModule, RecordContentSkeletonComponent, RecordContentSkeletonModule, RecordCreateAction, RecordDetailsPopupButtonComponent, RecordDetailsPopupButtonModule, RecordEditAction, RecordFetchGQL, RecordFlexboxComponent, RecordFlexboxModule, RecordGridComponent, RecordGridModule, RecordHeaderComponent, RecordHeaderModule, RecordListModalComponent, RecordListModalModule, RecordListModalStore, RecordListModalStoreFactory, RecordListStore, RecordListStoreFactory, RecordManager, RecordModule, RecordPanelActionHandler, RecordPanelActionManager, RecordPanelAdapter, RecordPanelComponent, RecordPanelModule, RecordPanelStore, RecordPanelStoreFactory, RecordSaveAction, RecordSaveGQL, RecordSaveNewAction, RecordStore, RecordStoreFactory, RecordStoreList, RecordThreadComponent, RecordThreadItemActionHandler, RecordThreadItemActionManager, RecordThreadItemActionsAdapter, RecordThreadItemActionsAdapterFactory, RecordThreadItemCancelAction, RecordThreadItemComponent, RecordThreadItemEditAction, RecordThreadItemModule, RecordThreadItemSaveAction, RecordThreadItemStore, RecordThreadItemStoreFactory, RecordThreadListActionHandler, RecordThreadListActionManager, RecordThreadListActionsAdapter, RecordThreadListActionsAdapterFactory, RecordThreadModule, RecordThreadSidebarWidgetComponent, RecordThreadSidebarWidgetModule, RecordThreadStore, RecordThreadStoreFactory, RecordToggleWidgetsAction, RecordViewSidebarWidgetService, RecordViewStore, RecoverPasswordService, RedirectAsyncAction, RelateDetailFieldComponent, RelateDetailFieldsModule, RelateEditFieldComponent, RelateEditFieldModule, RelateFilterFieldComponent, RelateFilterFieldModule, RelateService, RequiredAction, RequiredValidator, RouteConverter, RunBulkActionRecordPanelAction, SaveFilterStoreFactory, SavedFilterActionAdapterFactory, SavedFilterActionHandler, SavedFilterActionManager, SavedFilterActionsAdapter, SavedFilterDeleteAction, SavedFilterRecordStore, SavedFilterRecordStoreFactory, SavedFilterSaveAction, SavedFilterSaveGQL, SavedFilterStore, SavedSearchRecordMapper, ScreenSize, ScreenSizeObserverService, SearchBarComponent, SearchBarModule, SelectColumnsTableAction, SelectModalService, SeriesMapper, SeriesStatisticsStore, SeriesStatisticsStoreFactory, SeriesTraverser, SettingsMenuComponent, SettingsMenuModule, SidebarComponent, SidebarWidgetAdapter, SidebarWidgetComponent, SidebarWidgetModule, SidebarWidgetRegistry, SingleValueStatisticsStore, SingleValueStatisticsStoreFactory, SortButtonComponent, SortButtonModule, StandardFieldRegistry, StateManager, StatisticsBatch, StatisticsFetchGQL, StatisticsSidebarWidgetComponent, StatisticsSidebarWidgetModule, StatisticsStore, StatisticsStoreFactory, StatisticsTopWidgetComponent, StatisticsTopWidgetModule, StatusBarComponent, StatusBarModule, SubMenuFavoritesComponent, SubMenuFavoritesRegistry, SubMenuRecentlyViewedComponent, SubMenuRecentlyViewedRegistry, SubpanelActionAdapterFactory, SubpanelActionHandler, SubpanelActionManager, SubpanelActionsAdapter, SubpanelClearFilterAction, SubpanelComponent, SubpanelContainerComponent, SubpanelContainerModule, SubpanelCreateAction, SubpanelFilterAdapter, SubpanelFilterAdapterFactory, SubpanelLineActionHandler, SubpanelLineActionManager, SubpanelLineActionsAdapter, SubpanelLineActionsAdapterFactory, SubpanelModule, SubpanelSelectAction, SubpanelShowFilterAction, SubpanelStore, SubpanelStoreFactory, SubpanelTableAdapter, SubpanelTableAdapterFactory, SystemConfigStore, SystemNameService, TableActionHandler, TableActionManager, TableAdapter, TableBodyComponent, TableBodyModule, TableComponent, TableFooterComponent, TableFooterModule, TableHeaderComponent, TableHeaderModule, TableModule, TextDetailFieldComponent, TextDetailFieldModule, TextEditFieldComponent, TextEditFieldModule, TextListFieldComponent, TextListFieldModule, ThemeImagesStore, TinymceDetailFieldComponent, TinymceDetailFieldModule, TinymceEditFieldComponent, TinymceEditFieldModule, ToObservableModule, ToObservablePipe, TopWidgetAdapter, TopWidgetComponent, TopWidgetModule, TruncatePipe, UpdateBaseCurrencyAction, UpdateCurrencyAction, UpdateFlexRelateModuleAction, UpdateValueAction, UpdateValueBackendAction, UrlDetailFieldComponent, UrlDetailFieldModule, UserPreferenceStore, UserService, ValidationManager, VarcharDetailFieldComponent, VarcharDetailFieldModule, VarcharEditFieldComponent, VarcharEditFieldModule, VarcharFilterFieldComponent, VarcharFilterFieldModule, VerticalBarChartComponent, VerticalBarChartModule, ViewStore, WidgetPanelComponent, WidgetPanelModule, alertTypes, baseFieldComponents, baseFieldModules, baseObjectFieldsTypeMap, baseViewFieldsMap, booleanRequiredValidator, chartModules, chartTypeMap, componentTypeMap, currencyValidator, dateTimeValidator, dateValidator, duplicateEmailValidator, emailValidator, fieldComponents, fieldModules, floatValidator, intValidator, maxValidator, minValidator, multienumRequiredValidator, phoneValidator, primaryEmailValidator, requiredValidator, sidebarWidgetModules, topWidgetComponentTypeMap, topWidgetModules, viewFieldsMap };
//# sourceMappingURL=core.mjs.map
